Jump to content

Help with Forum Code Please


wilko88

Recommended Posts

Hey Guys,

 

this is my code so far below, but I keep getting this error:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/wscologn/public_html/phptesting/index.php on line 10

 

<?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 jS F Y g.iA",

strtotime($row['dateposted'])) .

"</i>";

echo "<p>";

echo nl2br($row['body']);

echo "</p>";

 

require("footer.php");

 

?>

 

Any advice or help would be appreciated.

 

Cheers,

Dan

Link to comment
https://forums.phpfreaks.com/topic/166963-help-with-forum-code-please/
Share on other sites

Try changing

 

$sql = "SELECT entries.*, categories.cat FROM entries, categories
   WHERE entries.cat_id = categories.id
   ORDER BY dateposted DESC
   LIMIT 1;";

to

$sql = "SELECT entries.*, categories.cat FROM entries, categories
   WHERE entries.cat_id = categories.id
   ORDER BY dateposted DESC
   LIMIT 1"; 

 

also put code tags around your scripts.

 

Also, if you're having problems with queries you should do this

 

mysql_query()or die(mysql_error());

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.