Hi there! A total newbie in php... We have a register over our resellers. The hostingcompany where our website is currently hosted has just upgraded the PHP version to the latest one. After this upgrade I got the following error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource when trying to access a reseller. A bit from the code (that an consultant has wrote like 3 years ago): <? $result = mysql_query("SELECT * FROM retailer WHERE regionID=$regionID ORDER BY regionID DESC, isHeadOffice DESC, name"); ?> <? while($retailer = mysql_fetch_array($result)){ ?> Please help!
Doesn't the query itself give an error? Or the mysql_connect or mysql_select_db instructions? Try something like this and see what result it gives you: $result = mysql_query("SELECT * FROM retailer WHERE regionID=$regionID ORDER BY regionID DESC, isHeadOffice DESC, name") or die("MySQL error : ".mysql_errno()." - ".mysql_error());
<? $result = mysql_query("SELECT * FROM retailer WHERE regionID='$regionID' ORDER BY regionID DESC, isHeadOffice DESC, name"); ?> PHP: May be missiong single quotes for $regionID is a reson.
if $regionID is a string, you should put a single quote before and after the variable. But if $regionID is an integer value, your code is correct. Just make sure that it's really an integer value. Maybe ....regionID = " . intval($regionID) . " ORDER BY would help.