Forum Moderators: coopster
Can anyone possibly help me understand why the following query is producing:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
[php]
<?
include("../config.php");
// Connect to database
$cid = mysql_connect($host,$username,$dbpass);
if (!$cid) { echo("ERROR: " . mysql_error() . "\n"); }
mysql_select_db("$db");
// define the maximum results to show (set in config file)
$max_results = $max_articles;
// Get the data from the Database
$query = "SELECT article_id, name, date from Articles LIMIT $max_results ORDER BY article_id DESC";
$result = mysql_db_query($db,"$query",$cid);
if (!$result) { echo("ERROR: " . mysql_error() . "\n$result\n"); }
while($row=mysql_fetch_array($result))
{
?>
<tr class="row-a">
<td class="first"><? echo("$row[date]");?></td>
<td><a href="article-<? echo("$row[article_id]");?>"><? echo("$row[name]");?></a></td>
</tr>
<?
} // end of while statement - getting results from DB
?>
[/php]
Any help would be greatly appreciated :)
there appears to be a prob with my limit / order by code too :(
i had to remove this as well ' LIMIT $max_results ORDER BY article_id DESC' to get it to display results.
does anyone have any ideas as to what is wrong with the limit / order by?