#33635 [Fbk->Opn]: "couldn't fetch mysqli" error when attempting to write session data to db
| From: | tony at marston-home dot demon dot co dot uk | Date: | Sun, 10 Jul 2005 20:11:20 +0000 |
| Subject: | #33635 [Fbk->Opn]: "couldn't fetch mysqli" error when attempting to write session data to db | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-81642@lists.php.net to get a copy of this message | ||
ID: 33635
User updated by: tony at marston-home dot demon dot co dot uk
Reported By: tony at marston-home dot demon dot co dot uk
-Status: Feedback
+Status: Open
Bug Type: MySQLi related
Operating System: Windows XP
PHP Version: 5CVS-2005-07-10 (dev)
New Comment:
The full test set can be downloaded from
http://www.tonymarston.net/test.zip
Previous Comments:
------------------------------------------------------------------------
[2005-07-10 21:56:10] sniper@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc.
If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.
------------------------------------------------------------------------
[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