mysql_close(): supplied argument is not a valid MySQL-Link resource

Posted by maxedison on Stack Overflow See other posts from Stack Overflow or by maxedison
Published on 2011-01-14T22:50:15Z Indexed on 2011/01/14 22:53 UTC
Read the original article Hit count: 94

Filed under:
|

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.


© Stack Overflow or respective owner

Related posts about mysql

Related posts about error