Long ago forgot where to copy, always use, but upgrade to PHP5.5 is not good with the warning
The server can not modify php.ini had to try to write with mysqli, but has not written out please expert advice!!
Thank you
function connect_db () {
$db _connect =
Mysql_connect ("host_name", "user_name", "password")
Or Die ("Could not Connect");
return $db _connect;
}
function open ($save _path, $session _name) {
Global $db;
$db = connect_db ();
return true;
}
function Close () {
return true;
}
function Read ($id) {
Global $db;
mysql_select_db ("db_name");
$result = mysql_query ("SELECT *
From session_t
WHERE session_id= ' {$id} ');
if (mysql_num_rows ($result) = = 1) {
$row = Mysql_fetch_array ($result);
return $row [' Session_data '];
} else {
Return "";
}
}
function Write ($id, $sess _data) {
Global $db;
mysql_select_db ("db_name");
$result = mysql_query ("SELECT *
From session_t
WHERE session_id= ' {$id} ');
if (mysql_num_rows ($result) = = 1) {
$result = mysql_query ("UPDATE session_t
SET session_data= ' {$sess _data} '
WHERE session_id= ' {$id} ');
}else{
$date = Date (' y-m-d h:i:s ');
$result = mysql_query ("INSERT into session_t
VALUES (' {$id} ',
' {$sess _data} ', ' {$date} ') ';
}
return true;
}
function Destroy ($id) {
Global $db;
mysql_select_db ("db_name");
$result = mysql_query ("DELETE from session_t
WHERE session_id= ' {$id} ');
return true;
}
Function gc ($maxlife _time) {
return true;
}
Session_set_save_handler
("Open", "close", "read", "write", "Destroy", "GC");
?>
Reply to discussion (solution)
Change Mysql_ to Mysqli_.
> Change Mysql_ to Mysqli_
Moderator AH ~ So change no more wrong!!!!!
Warning:session_start (): Cannot send session cookie-headers already sent by
warning:mysqli_select_db () expects exactly 2 parameters, 1 given in
Warning:mysqli_num_rows () expects parameter 1 to BES Mysqli_result, null given in
Warning:mysqli_query () expects at least 2 parameters, 1 given in
Deprecated:mysql_connect (): The MySQL extension is Deprecated and would be a removed in the Future:use mysqli or PDO Instea D in
I'm sorry, the last deprecated didn't stick wrong.
Just waiting for you.
It's normal to make an error, just change it.
Not error and work is not normal, is the trouble
Error mysqli function because the default database connection Word cannot be
You can take $db as the first parameter of the function of error.
OK, thank you, moderator.