Jump to content

supplied argument is not a valid MySQL result resource


maxudaskin

Recommended Posts

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);
						}
						?>

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";
    }

?>

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π

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.