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
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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.