Jump to content

Problems with mysql_query's, and mysql_fetch_array()


clonetrooper9494

Recommended Posts

I am making a Chat Room. I have the posting part down, now, I just need help with displaying the posts. It doesn't seem to be doing the While part. I no I didn't misspell the name of the columns, and there are rows in the posts table. The DB.php is the same I use in the post.php page. I don't understand why it isn't echoing the rows!

<?phprequire_once 'db.php';$result = db_query("SELECT * FROM posts WHERE room='test'");  echo "<table border='0'>";    while($row = mysql_fetch_array($result))   {   echo "<tr><td width='75' align='right' valign='top'>".$row['username']."[".$row['date']."]:</td>";   echo "<td width='400' align='left'>".$row['text']."</td></tr>";   }echo "</table><a name='bottom'>"; ?>

Link to comment
Share on other sites

Are you sure the query works? You can also use mysql_num_rows() to check whether it actually selects anything.

Link to comment
Share on other sites

There's nothing wrong with the code, if the information in db.php is correct and if there is data in the database then you will see it printed. Use mysql_error to check for error messages with connecting to the database, but if there was an error there then the later statements would be failing and giving errors. Are error messages enabled?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...