SQL multiple select where a= blah OR blah OR blah

I am working on a script to generate xml feed for oodle and vast.
I would like to select multiple category ids in an sql statement.
The select statement looks like this:

$sql = “select * from ec4_ad where catid=$feed_id order by link_id”;

The category is defined in a long array like this:


I would like to have something like this:


So I ultimately want in the first line: $feed_id = 575,574,569
($feed_id to represent multiple values)

Do you know a way to do this?


SELECT foo FROM bar WHERE id IN (1,2,3,4);

I changed the lines to:



$sql = “select * from ec4_ad where catid IN ($feed_id) order by link_id”;

and get error

Parse error: syntax error, unexpected ‘,’ in /home/alabam/public_html/xml/savefeed.php on line 166

Try putting quotes arround it

I did:


and it seems to be working fine now.

Thank you so much for the help.


You need to read up on basic PHP and MySQL…

vali, that’s pretty useless as far as advice goes

especially after the original poster has said that it works fine now

The guy missed the " for a string variable, that means 100% that hes only modifying some script done by someone else, and that it’s the first time he works with php code.

I’m suggesting he speed reads some PHP quick start guide or something.

This might be of some help: http://www.w3schools.com/php/php_syntax.asp