$threadID=$_GET['threadID'];
$result=mysql_query("
SELECT * FROM threads AS Threads
INNER JOIN users AS Users ON Threads.user_id=Users.user_id
WHERE thread_id='$threadID' LIMIT 1
") or die(mysql_error());
I get this:
u have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near ”11′ at
line 3
I wrote many inner joins before. Why is my syntax wrong near the end of the query
updated: 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 ’12’ LIMIT 1′ at line 3
First of all, your query is WIDE open to sql injection attacks.
Second, to figure out why you get the syntax error, make the query building phase separate from the actual query call:
This way you can see the entire query. MySQL’s error messages only report the portion of the query from where it thinks the error is onwards, but sometimes it decides wrong and elminates the actual relevant part where th error is… so… examine the ENTIRE query.