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
https://forums.phpfreaks.com/topic/68148-mysql_fetch_array-problem/
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!

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.