mysql_close(): supplied argument is not a valid MySQL-Link resource
- by maxedison
I'm trying to get the hang of using custom session handlers to store session data in a MySQL database. However, I keep getting the following warning:
mysql_close(): supplied argument is not a valid MySQL-Link resource
Here's the code I'm using, which I got from here:
function _open(){
global $_sess_db;
$_sess_db = mysql_connect("localhost", "root", "******");
if ($_sess_db) {
return mysql_select_db('style', $_sess_db);
}
return false;
}
function _close(){
global $_sess_db;
return mysql_close($_sess_db); //error happens here
}
The full text of the error message ultimately points to the final "return mysql_close($_sess_db);" line. I can confirm that the mysql_connect info does in fact work, and I do have the rest of the session handler functions defined as well.
And in case it helps, I get these errors immediately upon page load, without actually calling any of the session handler functions, and without having any current sessions open.