Mysql_close (): the provided argument is not a valid MySQL-Link resource

I am trying to use custom session handlers to store session data in a MySQL database. However, I continue to receive the following warning:

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

Here is the code I use that 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 information really works, and I also have the rest of the session handler functions.

And in case this helps, I immediately get these errors when loading the page, without actually calling any functions of the session handler and not opening any current sessions.


+3
2

- . global , . $GLOBALS ['_ sess_db'] $_sess_db .

+3

_open() _close() , , , .

0

Source: https://habr.com/ru/post/1785555/


All Articles