Page 1 of 1

Error with query[TOPIC SOLVED]

Posted: Mon Aug 27, 2007 5:28 pm
by SirChick
Im getting this error:

Error: 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 'Resource id #5' at line 1 with query Resource id #5



But no idea what its trying to explain to me to fix... its the same query as used in the "elseif" part of my if statement which works 100% yet the exact same when copy n pasted doesnt lol!

How ever i have a second query in this "if" region which i guess could be it... can any one tell me what i have done wrong? Heres the 2 only possible queries that it could be:

Code: Select all

$CheckUserID = mysql_query("SELECT * FROM userregistrationWHERE UserID='$UserID'");
$GetUserID = mysql_query($CheckUserID) or die("Error: ". mysql_error(). " with query ". $CheckUserID);
							
If (!($row = mysql_fetch_assoc($CheckUserID))) 
{
die('This Username does not exist!');
}


OR

Code: Select all

$secondquery = "INSERT INTO `messages` (Reciever, Sender, Senttime, MessageText, Subject)
Values ('$UserID', '$Sender', '$Date', '$MessageText', '$Subject')";
mysql_query($secondquery) or die(mysql_error(). " with query ". $secondquery); // get useful error message

Posted: Mon Aug 27, 2007 5:34 pm
by s.dot
You're querying a result.

Code: Select all

$CheckUserID = mysql_query("SELECT * FROM userregistrationWHERE UserID='$UserID'"); 
$GetUserID = mysql_query($CheckUserID) or die("Error: ". mysql_error(). " with query ". $CheckUserID);
Should just be

Code: Select all

$CheckUserID = mysql_query("SELECT * FROM userregistrationWHERE UserID='$UserID'") or die(mysql_error());

Posted: Mon Aug 27, 2007 6:08 pm
by SirChick
Right ok i got this though this time:

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 '='47'' at line 1


"47" is the input value that i put in myself to check


EDIT never mind its working .. i missed out a space to seperate the WHERE