Forum Moderators: coopster

Message Too Old, No Replies

"You have an error in your SQL syntax;"

"...check the manual that corresponds to your MySQL server version ..."

         

Conscientious Reject

4:38 pm on Mar 17, 2006 (gmt 0)

10+ Year Member



I have been banging my head trying to find out where this syntax error is. I think it is somewhere in the following I left a comment.

/*I get 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
'AND parent_thread = Thread.id AND in_reply_to IS NULL' at line 2*/
$query = "SELECT id, author, date, body, FROM Post
WHERE parent_thread = ". $_GET['threadID'];
$result = mysql_query($query);
if ($result == 0)
{
echo "Error: " . mysql_error();
}

Conscientious Reject

4:42 pm on Mar 17, 2006 (gmt 0)

10+ Year Member



I am also getting an error on another script using the same object. Just so everyone knows I think that I am mixing mysqli with mysgl, but I just can't see it.

/*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 'AND parent_thread = Thread.id AND in_reply_to IS NULL' at line 2*/
$query = "SELECT Thread.*, date, author FROM Thread, Post WHERE
parent_topic =" . $_GET['topicID'] . " AND
parent_thread = Thread.id AND
in_reply_to IS NULL";
$result = mysql_query($query);
if ($result == 0)
{
echo "<b>Error: ";
echo mysql_error()."</br>";
}

Conscientious Reject

5:58 pm on Mar 17, 2006 (gmt 0)

10+ Year Member



Okay,
I named a datacell wrong in on of my tables: where it was Id it is now id.
And yet another error when I fixed the db table cell name (because it was named wrong as Id)
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 'FROM Post WHERE parent_thread =' at line 1

phpmaven

2:32 pm on Mar 18, 2006 (gmt 0)

10+ Year Member



Why don't you echo your sql statement to the screen and paste it here so we can see what MySQL is actually executing?

mikesmith76

3:04 pm on Mar 18, 2006 (gmt 0)

10+ Year Member



$query = "SELECT id, author, date, body, FROM Post
WHERE parent_thread = ". $_GET['threadID'];

You have a stray , after 'body' in the query above. Remove that and it should work

Conscientious Reject

5:26 am on Mar 20, 2006 (gmt 0)

10+ Year Member



Thanks,
Ill give it shot and see how it works out.