php help
#1

I have this code:

Код:
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);
}
But gives me:

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')");
}
Error:

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.

How to fix?
Reply


Messages In This Thread
php help - by Face9000 - 28.12.2016, 20:25
Re: php help - by BlackBank - 29.12.2016, 13:15
Re: php help - by Vince - 29.12.2016, 14:10

Forum Jump:


Users browsing this thread: 1 Guest(s)