Admin from Windows to Unix

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
rexexdesign
Forum Newbie
Posts: 5
Joined: Thu Nov 02, 2006 10:29 am

Admin from Windows to Unix

Post by rexexdesign »

Hey everybody...

I have a BIG problem. I had to move a fully functional admin from a windows server to a unix server. I don't know if that's even the problem, or just the fact, that the MYSQL version is different. Anyway, in the Admin (php) the programmer used a lof of queries with IN().
i.e. : $sql = "SELECT image FROM product_images WHERE image LIKE('".$sku."%') AND product_id IN (SELECT id FROM products WHERE season_id = ".$season_id.");";

That doesn't work at all on the new server. Is there a workaround, maybe a join or something else I can replace that with? Its hard to find anything on google with a search term like " mysql_query + IN( +problem ". ;)

Anyway, any help is appreciated!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

IN has been supported by mysql for a long time. I doubt you have an older version.
try

Code: Select all

echo '<div>Debug: ', htmlentities($sql), "</div>\n";
and check the printed sql statement
bdlang
Forum Contributor
Posts: 395
Joined: Tue May 16, 2006 8:46 pm
Location: Ventura, CA US

Post by bdlang »

rexexdesign wrote:That doesn't work at all on the new server.
Define "doesn't work".

I don't know that IN is your problem, but I notice you're using a subquery. If you're working with MySQL < v4.1, this doesn't work.

Does the query fail if you enter it manually into MySQL with string literals replacing the variables?

Where do the values for $sku and $season_id get set? Do they have a value?

Have you used mysql_error() to troubleshoot your script?

+1 to volka.
rexexdesign
Forum Newbie
Posts: 5
Joined: Thu Nov 02, 2006 10:29 am

Subquery

Post by rexexdesign »

You were right, it does have to do with the subquery. IN ( 1985, 1986, 1987 ) works. But the query in the IN () statement is what breaks it. I did the query ahead of the one with IN () and then placed the output in the between the IN () and now it works.

Thanks for all the help!
Post Reply