[SOLVED] What is wrong with this query?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

What is wrong with this query?

Post 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 =).
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

what does this line look like once the variables are filled in for this particular query?
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post 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
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Actually, I solved this problem. $limit wasn't getting a proper value. Thanks fyed.
Post Reply