[Solved]mysql_fetch_array() problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
techkid
Forum Commoner
Posts: 54
Joined: Sat Sep 05, 2009 11:18 pm
Location: Maldives

[Solved]mysql_fetch_array() problem

Post by techkid »

I'm having a problem with blog.php file.

Blog.php?act=view&id=6 <-- this one shows individual post
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\supp\b-class.php on line 17

Here is the code for that part

Code: Select all

//view the news article!
if(isset($_GET['act']) && $_GET['act'] == "view")
{
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM content WHERE index = '$id'");
while($row = mysql_fetch_array($sql))
{
echo "<div id='post'>";
echo "<h3>" . $row['title'] . "</h3>";
echo '<a href="blog.php?act=view&id='.$row['index'].'">'.$row['title'].'</a>';
echo $row['news'];
echo '<p class="postend">Posted by: '.$row['author'].' | Date:'.$row['date'].'</p></div>';
}
Here is the database scheme:
Image
Last edited by techkid on Sun Sep 06, 2009 12:54 am, edited 1 time in total.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: mysql_fetch_array() problem

Post by requinix »

Use mysql_error to get an error message.

Oh, and
techkid wrote:Here is the database scheme:
Yeah... The picture isn't all that useful.
Post Reply