Page 1 of 1

What is wrong with this query?

Posted: Wed Jul 28, 2004 8:59 pm
by evilmonkey

Code: Select all

SELECT `id` FROM `users` WHERE `gender` LIKE '$gender' 
AND `status` LIKE '$status' AND `age` > $age_from AND `age` < $age_to AND `has_pic` = 'Y'
LIMIT $limitvalue, $limit
mysql_error() tells me this: 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 '' at line 3. Not too informative :x . Plase help...

(Possbile values variables include %, as well as values, hence the LIKE instead of =).

Posted: Wed Jul 28, 2004 9:02 pm
by feyd
what does this line look like once the variables are filled in for this particular query?

Posted: Wed Jul 28, 2004 9:22 pm
by evilmonkey
SELECT `id` FROM `users` WHERE `gender` LIKE '%'
AND `status` LIKE '%' AND `age` > 13 AND `age` < 26 AND `has_pic` = 'Y' LIMIT 0, 10

Posted: Wed Jul 28, 2004 9:27 pm
by evilmonkey
Actually, I solved this problem. $limit wasn't getting a proper value. Thanks fyed.