28.12.2016, 20:25
I have this code:
But gives me:
------------
Second code:
Error:
How to fix?
Код:
function new_session($userid, $lifespan="3600", $ipvoid) { global $vip, $Db1; $expirytime = (string) (time() - $lifespan); $delresult = $Db1->query("DELETE FROM sessions WHERE start_time<$expirytime or user_id='$userid'"); $found=false; do { $sessid = rand_string(20); $sessid2 = rand_string(5); $sql=$Db1->query("SELECT * FROM sessions WHERE (sess_id = '$sessid') AND (sess_id2='$sessid2')"); if($Db1->num_rows() == 0) { $found=true; } } while ($found == false); $currtime = (string) (time()); $sql = $Db1->query("INSERT INTO sessions SET sess_id='$sessid', sess_id2='$sessid2', user_id='$userid', start_time='$currtime', remote_ip='$vip', ipvoid='$ipvoid' "); return array($sessid, $sessid2); }
Quote:
Database error: Invalid SQL: INSERT INTO sessions SET sess_id='1T1RrMk9UZ3dOVEU1TlR', sess_id2='1T1Rr', user_id='1', start_time='1482959789', remote_ip='***', ipvoid='' MySQL Error: 1366 (Incorrect integer value: '' for column 'ipvoid' at row 1) Session halted. |
Second code:
Код:
$fivemin=time()-60; $sql=$Db1->query("DELETE FROM online WHERE dsub<'$fivemin'"); $sql=$Db1->query("SELECT id FROM online WHERE ip='$vip' LIMIT 1"); if($Db1->num_rows() == 0) { $sql=$Db1->query("INSERT INTO online (userid, dsub, ip) VALUES ('$userid','".time()."','$vip')"); }
Quote:
Database error: Invalid SQL: INSERT INTO online (userid, dsub, ip) VALUES ('','1482960025','***') MySQL Error: 1366 (Incorrect integer value: '' for column 'userid' at row 1) Session halted. |