Jump to content

[SOLVED] mysql_fetch_array() error


odetron

Recommended Posts

I was useing the news system code on this site yet im haveing trouble when running part of it.

<?php

$db_host = "xxxxxxx";
$db_username = "xxxxxxxx";
$db_password = "xxxxxxx";
$db_name = "xxxxxxx";

mysql_connect($db_host,$db_username,$db_password) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());

$query = "SELECT name, subject, message, date
FROM news order by date DESC";
$result = mysql_query($query);

echo "<br><center>";

while($r=mysql_fetch_array($result))
{

echo "<tr>";
echo "<td bgcolor='#FFFFFF'><h10>// $r[subject]<HR color='#660000'></td>";
echo "</tr>";
echo "<tr>";
echo "<td bgcolor='#FFFFFF'>$r[message]<HR color='#660000'></h10></td>";
echo "</tr>";
echo "<tr>";
echo "<td bgcolor='#FFFFFF'>Posted By:
$r[name]</a>   $r[date]<br><br><br></td>";
echo "</tr>";
}
echo "</table>";

?>

Im haveing trouble running line 17. It looks right yet I get this message:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

How can I fix this?

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.