Hi.
I'm having a few problems with some code on my site.
Untill now, my "messages" function was...
PHP Code:
function messages() {
$sql = "SELECT * FROM messages";
$query = mysql_query($sql);
$count = mysql_num_rows($query);
?>
<tr>
<td class="table">There are currently <a href="messages.php"><b><?php echo $count ?></b></a> active messages.</td>
</tr>
<?php
}
...and everything worked fine.
However, I recently tried adding a new feature to the function and changed the code to this...
PHP Code:
function messages() {
$sql = "SELECT * FROM messages WHERE read='no'";
$query = mysql_query($sql);
$count = mysql_num_rows($query);
?>
<tr>
<td class="table">There are currently <a href="messages.php"><b><?php echo $count ?></b></a> unread messages.</td>
</tr>
<?php
}
...and the code no longer works. I am presented with this error message instead:
Quote:
|
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource.
|
I added the new field to the database and everything so it is set up correctly as far as I can tell, but I just can't understand why I'm getting this error.
I've been trying for a while to fix it and still just can't be sure what is causing the problem, so if someone could enlighten me I would be very grateful.
Thanks.
