Jump to content

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π

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.