bsamson Posted November 30, 2009 Share Posted November 30, 2009 <? ## CONNECT TO DB FUNCTION! function ConnectTo($db2con) { $hostName = "localhost"; $dbName = "people_".$db2con; $userName = "people_main"; $password = "normal123"; $link = mysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName"); mysql_select_db($dbName, $link) or die( "Unable to select database $dbName"); return $link; } $conn = ConnectTo("estore"); $query = "SELECT * FROM CubeCart_inventory"; $result = mysql_query($query) or die(mysql_error()); $num = mysql_num_rows($result); while ($row=mysql_fetch_array($result)) { $prod = $row['productId']; $cat = $row['categories']; } ?> I have the above code ... EVERYTIME it runs I get this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/people/public_html/code/xml/scripts/loadCatIDx.php I do not understand this problem! I understand the error is implying my query returned an error, however when I add echo mysql_num_rows($result) it returns over 2700 records ... Any help would be greatly appreciated!! Quote Link to comment https://forums.phpfreaks.com/topic/183384-strange-phpmysql-error-am-i-just-tired/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 30, 2009 Share Posted November 30, 2009 Your actual code inside of the while() loop is probably reusing and overwriting the $result variable. Quote Link to comment https://forums.phpfreaks.com/topic/183384-strange-phpmysql-error-am-i-just-tired/#findComment-967965 Share on other sites More sharing options...
bsamson Posted November 30, 2009 Author Share Posted November 30, 2009 THANK YOU!!!!! A "tired mans" mistake! Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/183384-strange-phpmysql-error-am-i-just-tired/#findComment-967967 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.