maxudaskin Posted October 16, 2007 Share Posted October 16, 2007 I get an error along the lines of: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/.grable/vzoom/virtualzoom.net/comm/forum_posts.php on line 284 <?php $gettopic = $_GET['t']; $forum_query = mysql_query("SELECT * FROM forum_posts WHERE topicid='{$gettopic}' ORDER BY postid DESC"); while($forum_array = mysql_fetch_array($forum_query)){ // Line 284 $forumname = $forum_array['forumid']; forum_name($forumname); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/73398-supplied-argument-is-not-a-valid-mysql-result-resource/ Share on other sites More sharing options...
trq Posted October 16, 2007 Share Posted October 16, 2007 Your query is more than likely failing and you have no error checking to catch it. Try... <?php if (isset($_GET['t'])) { $gettopic = $_GET['t']; $sql = "SELECT * FROM forum_posts WHERE topicid='{$gettopic}' ORDER BY postid DESC"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_array($result)) { $forumname = $row['forumid']; forum_name($forumname); } } else { echo "no results found"; } } else { echo mysql_error() . "<br />$sql"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/73398-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-370324 Share on other sites More sharing options...
easygenerated Posted October 18, 2007 Share Posted October 18, 2007 Your query is more than likely failing and you have no error checking to catch it. Try... <?php if (isset($_GET['t'])) { $gettopic = $_GET['t']; $sql = "SELECT * FROM forum_posts WHERE topicid='{$gettopic}' ORDER BY postid DESC"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_array($result)) { $forumname = $row['forumid']; forum_name($forumname); } } else { echo "no results found"; } } else { echo mysql_error() . "<br />$sql"; } ?> You might want to die the query @ 283: die($forum_query); Just put the result in the PHPMyAdmin, PHP warnings here will become quite intuitive MySQL errors like Unknown column 'postid' in 'field list' Patrick http://www.easy-generated.comπ Quote Link to comment https://forums.phpfreaks.com/topic/73398-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-372324 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.