From:             [EMAIL PROTECTED]
Operating system: Linux Mandrake 8.2
PHP version:      4.1.2
PHP Bug Type:     MySQL related
Bug description:  # is not a valid MySQL-Link resource

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!
-- 
Edit bug report at http://bugs.php.net/?id=17248&edit=1
-- 
Fixed in CVS:        http://bugs.php.net/fix.php?id=17248&r=fixedcvs
Fixed in release:    http://bugs.php.net/fix.php?id=17248&r=alreadyfixed
Need backtrace:      http://bugs.php.net/fix.php?id=17248&r=needtrace
Try newer version:   http://bugs.php.net/fix.php?id=17248&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17248&r=support
Expected behavior:   http://bugs.php.net/fix.php?id=17248&r=notwrong
Not enough info:     http://bugs.php.net/fix.php?id=17248&r=notenoughinfo
Submitted twice:     http://bugs.php.net/fix.php?id=17248&r=submittedtwice
register_globals:    http://bugs.php.net/fix.php?id=17248&r=globals

Reply via email to