php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17248 # is not a valid MySQL-Link resource
Submitted: 2002-05-15 09:19 UTC Modified: 2002-08-04 04:46 UTC
Votes:12
Avg. Score:4.3 ± 0.8
Reproduced:12 of 12 (100.0%)
Same Version:5 (41.7%)
Same OS:2 (16.7%)
From: bbs at c-se dot de Assigned:
Status: No Feedback Package: MySQL related
PHP Version: 4.1.2 OS: Linux Mandrake 8.2
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bbs at c-se dot de
New email:
PHP Version: OS:

 

 [2002-05-15 09:19 UTC] bbs at c-se dot de
Hi!

I just recently switched an application from Debian Woody with PHP 4.0.3 PL1 to Mandrake Linux 8.2 / PHP 4.1.2 (as an RPM out of the box). The same script that worked fine for over a year now makes trouble on the new machine:

    /*  two function definitions */

    Create_DB_Connection($verbindung_lfz) OR
        ErrorMsg("Module", "connection could not be created");

    if ($kdnrClub)
    {
        /* GetUserData creates its own connection to the db and closes it after
           use */
        GetUserData($SID, $row);
        [...]
    }
    [...]
    /* some php-code and some db-queries with $verbindung_lfz but different
       $result-vars */
    [...]
     
    if (! $verbindung_lfz)
    {
        print "No connection!<br>";
    }
    else
    {
        print "Connection ok!<br>";
    }

    SQLExec($statement, $verbindung_lfz, $result_lfz) OR
        ErrorMsg("Luftfahrzeug", "couldn't get data: " . mysql_error());

The connection still exists because there is the "Connection ok!" message. Right after that my SQLExec blows up and gives 

    Warning: [some number] is not a valid MySQL-Link resource in [...]

Later, the connection can't be closed because it does not exist. But why does my connection-check work before I call SQLExec?
    
The SQL-statement is working fine on the console. My query works if I move it to the beginning of the script after the Create_DB_Connection.

I replaced my wrapping functions with the original functions-calls but that didn't make a difference.

I've got some kind of framework for my database connections. These are the used functions in this excerpt:

    function Create_DB_connection(&$newconnect)
    {
        $db_user    = $GLOBALS["CONST_DB_USER"];
        $db_host    = $GLOBALS["CONST_DB_HOST"];
        $db_pass    = $GLOBALS["CONST_DB_PASS"];

        $retval         = 1;
        $newconnect = mysql_connect($db_host, $db_user, $db_pass) or
            $retval = 0;
        return $retval;
    }

    function SQLExec($sqlquery, $viaconnection, &$resultset)
    {
        $db_base    = $GLOBALS["CONST_DB_BASE"];

        $retval     = 1;
        $resultset  = mysql_db_query($db_base, $sqlquery, $viaconnection) or
            $retval = 0;

        return $retval;
    }

So what changed between 4.0.3PL1 und 4.1.2 to cause this behaviour? There are some more scripts and I'd like to have an idea about what I should take care of.

Thanks!

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-15 09:26 UTC] mfischer@php.net
It seems like a bug in your code/logic. Please paste a small, self-contained example showing the problem. Also make sure you run everything with error_reporting(E_ALL);
 [2002-08-04 04:46 UTC] georg@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2007-08-18 17:58 UTC] warren dot gutierrez at gmail dot com
The mysql_db_query() function is no longer used 4.0.6 up. You may want to use mysql_select_db() and mysql_query() instead. Hope this helps.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC