what is wrong with this sql query. i cant figure it out.
$query = "SELECT *
FROM tagPairs
WHERE (tag1Id IN ($tag1Id, $tag2Id))
AND (tag2Id IN ($tag1Id, $tag2Id))";
error code:
Couldn’t execute query: 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 (tag2Id IN (, ))’ at line 3
thanks in advance!
$tag1Idand$tag2Idare both null, or empty strings. The simplest solutions is probably to explicitly cast them into numerical values:$tag1Id = intval($tag1Id); $tag2Id = intval($tag2Id); $query = "SELECT * FROM tagPairs WHERE (tag1Id IN ($tag1Id, $tag2Id)) AND (tag2Id IN ($tag1Id, $tag2Id))";