Jump to content

mysql_fetch_array problem


bigggnick

Recommended Posts

Hello all,

 

I'm writing an article system so people can write articles on my website. This is my first "big" project in PHP.  In the section where an admin can either approve or deny the article, I keep getting this error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in articles/admin/show_article_admin.php on line 10

 

Here is the code for that file:

<?php

include "../config.php";

$article_name = mysql_real_escape_string(htmlentities($_REQUEST['article_name']));



  $result = mysql_query("SELECT article_content, auth_name FROM articles WHERE article_name='$article_name' ");
  while($row = mysql_fetch_array($result, MYSQL_BOTH)){
echo '<h1>' . $row[article_name] . '</h1>';
echo 'By:' . $row[auth_name];
echo $row[article_content];
echo 'Would you like to approve this article?';
echo '<a href="approve_deny.php?article_name=$article_name&approved=yes">YES</a><a href="approve_deny.php?article_name=$article_name&approved=no">NO</a>';
}


?>

Link to comment
Share on other sites

Perhaps its that you've set not order?

 

mysql_query("SELECT article_content, auth_name FROM articles WHERE article_name='$article_name' order by id desc");

 

replace the 'id' with what ever your using to list their id's

 

Hope this worked!

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.