Jump to content

[SOLVED] SQL Syntax error


TGWSE_GY

Recommended Posts

Every time I run my login system and it gets to activity.php and MYSQL errors out with

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '', '04-12-09', '22:25:14', '')' at line 1

 

<?php

// Set login credentials
include('config.php');

$con = mysql_connect($Host, $Login, $Pass);

$Date 		= date('m-d-y');
$Start		= date('H:i:s');
$IP			= $_SERVER['Remote_ADDR'];
$cID = mysql_query("SELECT CustID FROM Login WHERE Usr = '$varUser'");

mysql_select_db("login_ums", $con);
//$testActive = mysql_query("SELECT * FROM 'ActiveUsers' WHERE Usr = '$varUsr'");
$testActive = mysql_query("SELECT * FROM `ActiveUsers` WHERE Usr = '$varUsr'") or die(mysql_error());
if (mysql_num_rows($testActive)) {
	include('suspect.php');
	die('That user is already logged in, please try again or contact the webmaster');
} else {
	mysql_query("INSERT INTO ActiveUsers ( CustID,Usr,Date,Start,IP ) VALUES ('$cID', $varUsr', '$Date', '$Start', '$IP')") or die(mysql_error()); <------ This line is where the error is occurring
	mysql_close($con);
	include('set_cookie.php');
}	 
?>

 

 

Any help would be appreciated I have been trying to fix this for hours.

 

Thanks Guys!  ;D

Link to comment
https://forums.phpfreaks.com/topic/153824-solved-sql-syntax-error/
Share on other sites

Thanks guys, mandred I did what you said and I have a new error

 

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/.deceasing/thegayestever/thegayestcommunityever.com/dev/php/includes/content/login_2/activity.php on line 16

 

<?php

// Set login credentials
include('config.php');

$con = mysql_connect($Host, $Login, $Pass);

$Date 		= date('m-d-y');
$Start		= date('H:i:s');
$IP			= $_SERVER['REMOTE_ADDR'];



mysql_select_db("login_ums", $con);
//$cID = mysql_query("SELECT CustID FROM `login` WHERE Usr = '$varUsr'") or die(mysql_error());
$custident = mysql_result(mysql_query("SELECT CustID FROM Login WHERE Usr = '$varUser'"), 0); <--error here
//$testActive = mysql_query("SELECT * FROM 'ActiveUsers' WHERE Usr = '$varUsr'");
$testActive = mysql_query("SELECT * FROM ActiveUsers WHERE Usr = '$varUsr'") or die(mysql_error());
if (mysql_num_rows($testActive)) {
	include('suspect.php');
	die('That user is already logged in, please try again or contact the webmaster ');
} else {
	mysql_query("INSERT INTO ActiveUsers ( CustID,Usr,Date,Start,IP ) VALUES ('$custident', '$varUsr', '$Date', '$Start', '$IP')") or die(mysql_error());
	mysql_close($con);
	include('set_cookie.php');
}	 
?>

 

Thanks again guys, I appreciate all the help!  ;D

It was set on the calling script, anyways its fixed I was not using the proper syntax with mysql_by_assoc(). Thanks for the help guys.!!!!!  ;D ;D ;D ;D ;D ;D ;D ;D ;D

 

Hmmm, don't see that in your script anywhere, unless I overlooked it.  At least it works.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.