Program works only when there are records :-(
| From: | Ryan A | Date: | Sun, 14 Sep 2003 21:44:31 +0000 |
| Subject: | Program works only when there are records :-( | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-162575@lists.php.net to get a copy of this message | ||
Hi,
I have a select statment with a UNION so that i am getting 5 COUNT(*)'s from
a table.
After that I have this code:
*****************************
$res = mysql_query($tt);
$num_rows = mysql_num_rows($res); //This is line 25
$x=1;
for($i=0; $i<5; $i++)
{
$a = mysql_result($res, $i); //This is line 30
$bb[$x]=$a;
$x++;
}
$one = $bb[1];
$two = $bb[2];
$thr = $bb[3];
$fou = $bb[4];
$fiv = $bb[5];
$tot=$one + $two + $thr + $fou + $fiv;
*****************************
When i have some records in the database this works fine and i get all the
values in $one,$two etc but when a new account is created and i the
COUNT(*) gets back just 0 I get these ugly errors/warnings on my page:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
resource in /usr163/home/b/e/bestweb/public_html/co.details.php on line 25
Warning: mysql_result(): supplied argument is not a valid MySQL result
resource in /usr163/home/b/e/bestweb/public_html/co.details.php on line 30
Warning: mysql_result(): supplied argument is not a valid MySQL result
resource in /usr163/home/b/e/bestweb/public_html/co.details.php on line 30
Warning: mysql_result(): supplied argument is not a valid MySQL result
resource in /usr163/home/b/e/bestweb/public_html/co.details.php on line 30
Warning: mysql_result(): supplied argument is not a valid MySQL result
resource in /usr163/home/b/e/bestweb/public_html/co.details.php on line 30
Warning: mysql_result(): supplied argument is not a valid MySQL result
resource in /usr163/home/b/e/bestweb/public_html/co.details.php on line 30
What should i do and wheres the problem? I searched on google but just found
some sites outputting this, no real help.
Totally confused, please help.
Thanks,
-Ryan