ID: 33635
User updated by: tony at marston-home dot demon dot co dot uk
-Summary: Get "couldn't fetch mysqli" error when attempting to
write session data to data
Reported By: tony at marston-home dot demon dot co dot uk
Status: Open
Bug Type: MySQLi related
Operating System: Windows XP
PHP Version: 5CVS-2005-07-10 (dev)
New Comment:
Title should read "when attempting to write session data to database"
Previous Comments:
------------------------------------------------------------------------
[2005-07-10 21:54:00] tony at marston-home dot demon dot co dot uk
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 this bug report at http://bugs.php.net/?id=33635&edit=1