thebusiness Posted July 16, 2011 Share Posted July 16, 2011 I am getting this error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /path/to/rockslider.inc.php on line 6 With this code <?php $sql = mysql_query("SELECT * FROM ava_slider ORDER BY id desc LIMIT 5"); while($row = mysql_fetch_array($sql)) { $rock_slider['title'] = $row['name']; $rock_slider['url'] = $row['url']; $rock_slider['description'] = $row['description']; $rock_slider['image'] = $row['image']; include $_SERVER['DOCUMENT_ROOT'] . '/includes/rock/rockslider.php'; } ?> Any help Quote Link to comment https://forums.phpfreaks.com/topic/242158-error-calling-array/ Share on other sites More sharing options...
gizmola Posted July 16, 2011 Share Posted July 16, 2011 Pretty much just what the error says. See link in my signature about mysql problems. Quote Link to comment https://forums.phpfreaks.com/topic/242158-error-calling-array/#findComment-1243596 Share on other sites More sharing options...
thebusiness Posted July 17, 2011 Author Share Posted July 17, 2011 Pretty much just what the error says. See link in my signature about mysql problems. Okay this is the error Could not successfully run query (Resource id #38) from DB: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #38' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/242158-error-calling-array/#findComment-1243598 Share on other sites More sharing options...
gizmola Posted July 17, 2011 Share Posted July 17, 2011 Seems to be unhappy with your query, although I don't understand that error message. What is the exact code you have right now? Quote Link to comment https://forums.phpfreaks.com/topic/242158-error-calling-array/#findComment-1243599 Share on other sites More sharing options...
thebusiness Posted July 17, 2011 Author Share Posted July 17, 2011 Seems to be unhappy with your query, although I don't understand that error message. What is the exact code you have right now? <?php $sql = mysql_query("SELECT * FROM ava_games ORDER BY id desc LIMIT 5"); $row = mysql_query($sql); if (!$row) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } while($row = mysql_fetch_array($sql)) { $rock_slider['title'] = $row['name']; $rock_slider['url'] = $row['url']; $rock_slider['description'] = $row['description']; $rock_slider['image'] = $row['image']; include $_SERVER['DOCUMENT_ROOT'] . '/includes/rock/rockslider.php'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/242158-error-calling-array/#findComment-1243602 Share on other sites More sharing options...
jcbones Posted July 17, 2011 Share Posted July 17, 2011 You are calling a query on a query. Change $sql to this: $sql = "SELECT * FROM ava_games ORDER BY id desc LIMIT 5"; Quote Link to comment https://forums.phpfreaks.com/topic/242158-error-calling-array/#findComment-1243603 Share on other sites More sharing options...
thebusiness Posted July 17, 2011 Author Share Posted July 17, 2011 You are calling a query on a query. Change $sql to this: $sql = "SELECT * FROM ava_games ORDER BY id desc LIMIT 5"; Now Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/hameda/public_html/gametako/includes/rock/rockslider.inc.php on line 13 Quote Link to comment https://forums.phpfreaks.com/topic/242158-error-calling-array/#findComment-1243606 Share on other sites More sharing options...
thebusiness Posted July 17, 2011 Author Share Posted July 17, 2011 You are calling a query on a query. Change $sql to this: $sql = "SELECT * FROM ava_games ORDER BY id desc LIMIT 5"; Now Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/hameda/public_html/gametako/includes/rock/rockslider.inc.php on line 13 this is current <?php $sql = "SELECT * FROM ava_games ORDER BY id desc LIMIT 5"; $row = mysql_query($sql); if (!$row) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } while($row = mysql_fetch_array($sql)) { $rock_slider['title'] = $row['name']; $rock_slider['url'] = $row['url']; $rock_slider['description'] = $row['description']; $rock_slider['image'] = $row['image']; include $_SERVER['DOCUMENT_ROOT'] . '/includes/rock/rockslider.php'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/242158-error-calling-array/#findComment-1243608 Share on other sites More sharing options...
thebusiness Posted July 17, 2011 Author Share Posted July 17, 2011 This worked <?php $sql = "SELECT * FROM ava_games ORDER BY id desc LIMIT 5"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ $rock_slider['title'] = $row['name']; $rock_slider['url'] = $row['url']; $rock_slider['description'] = $row['description']; $rock_slider['image'] = $row['image']; include $_SERVER['DOCUMENT_ROOT'] . '/includes/rock/rockslider.php'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/242158-error-calling-array/#findComment-1243614 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.