No errors,notices or warnings from PHP side and no errors from MySQL side.
Code: Select all
function session_write($id,$data)
{
if (substr(trim($data),0,6)=="SELECT")
$datum=addslashes(trim($data));
else
$datum=$data;
//echo $datum;
if (mysql_num_rows(mysql_query("SELECT * FROM Sessions WHERE id='".$id."'"))==0)
$SessRes=mysql_query("INSERT INTO Sessions VALUES('".$id."',NOW(),'".$_POST['User']."','".$datum."')");
else
$SessRes=mysql_query("UPDATE Sessions SET data='".$datum."',`time`=`time` WHERE id='".$id."'");
if (!$SessRes) die (mysql_error().'<BR><BR>'.$datum);
return true;
}In the first if-else it enters the first block as it should and $datum contains the add-slashed version of $data which is ok. In the second if-else, it enters the second block which is correct. The problem is $datum NEVER enters the `data` field. If I replace SET data='".$datum."',`time`=`time` with SET data='dummy',`time`=`time`, data gets the value dummy. So no problem with the sql statement.
But when a sql statement is to be written into a table...nothing happens - no error, warning - nothing. If I drop `time`=`time` even time gets updated to NOW() which it should since time is of type timestamp.
Any ideas ?
Thanks