Jump to content

[SOLVED] mysql_num_rows isn't returning anything?


spiceydog

Recommended Posts

I have a simple script that says if mysql_num_rows returns 0 than do something different. Unfortunately it doesn't do anything when mysql_num_rows SHOULD be equalling 0. Here is the relevant part of my code:

        <?php 
$recent = "SELECT * FROM messages WHERE user='$user' GROUP BY poster ORDER BY views DESC LIMIT 0, 5";
$result1 = mysql_query($recent) or die(mysql_error());
while ($row = mysql_fetch_array($result1)){
$date  = $row['date'];
$views  = $row['views'];
$post  = $row['post'];
$countresult1 = mysql_num_rows($result1) or die(mysql_error());
if ($countresult1 == '') {
echo "$gender hasn't posted anything yet.";
}
}
?>

 

Thanks in advance!

I really wish I could edit old posts. It would really help. Unfortunately I cant so here is my new problem that derived from my first.

 

So I thought everything worked but it turned out that for some reason my query returns 0 everytime which is weird. Here is my new script:

<?php 
$recent = "SELECT * FROM messages WHERE user='$user' GROUP BY poster ORDER BY date DESC LIMIT 0, 5";
$result1 = mysql_query($recent) or die(mysql_error());
if (mysql_num_rows($result1) == 0) {
echo "$gender hasn't posted anything yet.";
}
else {
while ($row = mysql_fetch_array($result1)){
$post  = $row['post'];
$date  = $row['date'];
?>

Archived

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

×
×
  • 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.