Jump to content

Supplied argument is not a valid MySQL result resource


gaugeboson

Recommended Posts

  I am having some trouble getting this tutorial to work.  Here is the code: 

<?php

require("header.php");

$sql = "SELECT entries.*, categories.cat FROM entries, categories
WHERE entries.cat_id = categories.id
ORDER by dateposted DESC
LIMIT 1;";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
echo "<h2><a href='viewentry.php?id" . $row['id']
. "'>" . $row['subject'] .
  "</a></h2><br />";
echo "<i>In <a href='viewcat.php?id=" . $row['cat_id']
."'>" . $row['cat'] .
  "</a> - Posted on ".date("D j F Y g.iA",
strtotime($row['dateposted'])) . 
  "</i>";
echo "<p>";
echo nl2br($row['body']);
echo "</p>";

echo "<p>";

$commsql = "SELECT name FROM comments WHERE blog_id = " . $row['id'] .
  "ORDER BY dateposted;";
$commresult = mysql_query($commsql);
[b]$numrows_comm = mysql_num_rows($commresult);[/b]
if($numrows_comm == 0) {
  echo "<p>No Comments.</p>";
}
else {
  echo "(<strong>" . $numrows_comm . " </strong>) comments : ";
  $i = 1;
  while($commrow = mysql_fetch_assoc($commresult)) {
    echo "<a href='viewentry.php?id=" . $row['id'] . "#comment" . $i . 
         "'>" . $commrow['name'] . "</a> ";
    $i++;
  }
}
echo "</p>";
$prevsql = "SELECT entries.*, categories.cat FROM entrie, categories
  WHERE entries.cat_id = categories.id
  ORDER BY dateposted DESC
  LIMIT 1, 5;";
$prevresult = mysql_query($prevsql);
$numrows_prev = mysql_num_rows($prevresult);

if($numrows_prev == 0) {
  echo "<p>No previous entries.</p>";
}
else {
echo "<ul>";

while($prevrow = mysql_fetch_assoc($prevresult)) {
  echo "<li><a href='viewentry.php?id="
. $prevrow['id'] . "'>" . $prevrow ['subject']
. "</a></li>";
  }
}
echo "</ul>";



require("footer.php");

?>

 

EDITED BY WILDTEEN88: Please use code tags (

[/coded]) when posting code.[/b]
Link to comment
Share on other sites

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.