clonetrooper9494 Posted August 31, 2008 Share Posted August 31, 2008 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 More sharing options...
Synook Posted August 31, 2008 Share Posted August 31, 2008 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 More sharing options...
jlhaslip Posted August 31, 2008 Share Posted August 31, 2008 run the query in phpmyadmin to see if the query works Link to comment Share on other sites More sharing options...
justsomeguy Posted September 2, 2008 Share Posted September 2, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.