Page 1 of 1

Admin from Windows to Unix

Posted: Thu Jun 07, 2007 3:52 pm
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!

Posted: Thu Jun 07, 2007 4:20 pm
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

Posted: Thu Jun 07, 2007 6:46 pm
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.

Subquery

Posted: Mon Jun 11, 2007 11:12 am
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!