Error with query[TOPIC SOLVED]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SirChick
Forum Contributor
Posts: 125
Joined: Tue Jul 31, 2007 11:55 am

Error with query[TOPIC SOLVED]

Post 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
Last edited by SirChick on Mon Aug 27, 2007 6:26 pm, edited 1 time in total.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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());
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
SirChick
Forum Contributor
Posts: 125
Joined: Tue Jul 31, 2007 11:55 am

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