Quantcast
Channel: Microsoft Drivers for PHP for SQL Server forum
Viewing all articles
Browse latest Browse all 391

sqlsrv_errors contain invalid type -> Using PHP custom session handling

$
0
0
Hi.

PHP spits out this if I try to connect to a SQL Server 2005 server in session handling functions:
PHP Fatal error: sqlsrv_errors contains an invalid type in (path)/session.php on line 29

Line 29 is wherre sqlsrv_connect is

When I use that OUTSIDE the session handling functions, it works fine, there are no problems what so ever.

Code to reproduce the problem:
function sess_open($save_path, $session_name)
{
return true;
}

function sess_close()
{
return true;
}

function sess_read($id)
{
return '';
}

function sess_write($id, $sess_data)
{ 
$connectionInfo = array( 
"UID"=>"MyUser",
"PWD"=>"MyPassword",
"Database"=>"MyDB" 
);

$conn = sqlsrv_connect("mySQLServer", $connectionInfo);

sqlsrv_query($conn,"SELECT 1 FROM sessions");

return true;
}

function sess_destroy($id)
{
return true;
}

function sess_gc($maxlifetime)
{
return true;
}

session_set_save_handler('sess_open', 'sess_close', 'sess_read', 'sess_write', 'sess_destroy', 'sess_gc');
session_start();


Viewing all articles
Browse latest Browse all 391

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>