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!

Link to comment
Share on other sites

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'];
?>

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.