From: tony at marston-home dot demon dot co dot uk
Operating system: Windows XP
PHP version: 5CVS-2005-07-10 (dev)
PHP Bug Type: MySQLi related
Bug description: Get "couldn't fetch mysqli" error when attempting to write
session data to data
Description:
------------
In my script I use a custom session handler to write all session data to
the database. Through versions 5.0.0 to 5.0.4 this worked as expected, but
with 5.0.5dev I am now getting an error. It only ever failos at the end of
the script when writing out the session data. It always fails at the same
place by generating a "Couldn't fetch mysqli" error.
Reproduce code:
---------------
function connect ($dbname)
// establish a connection to the database
{
global $dbhost, $dbusername, $dbuserpass;
static $dbconn;
if (!$dbconn) {
$dbconn = mysqli_connect($dbhost, $dbusername, $dbuserpass);
if ($dbconn) {
// use UTF8 for this connection
$this->query = "SET names 'UTF8'";
$result = mysqli_query($dbconn, $this->query) or
trigger_error($this, E_USER_ERROR);
} // if
} // if
if (!$dbconn) { <== FAILS HERE *********************
return false;
} elseif (!mysqli_select_db($dbconn, $dbname)) {
return false;
} else {
$this->dbconnect = $dbconn;
return true;
} // if
} // connect
The full code is available from http://www.tonymarston.net/text.zip. The
script to run is "test.php".
Expected result:
----------------
At that point $dbconn is shown to be "object of mysqli", so it should not
error.
Actual result:
--------------
At the line "if (!$dbconn)" the program jumps immediately to my error
handler with the error "Couldn't fetch mysqli".
--
Edit bug report at http://bugs.php.net/?id=33635&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33635&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=33635&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=33635&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33635&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33635&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33635&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33635&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33635&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33635&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33635&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=33635&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=33635&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33635&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33635&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33635&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33635&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33635&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33635&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33635&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33635&r=mysqlcfg