Start by giving us the value of $tt, ... That'll probably tell more about
the problem. Or you can do something like this:

if ($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++;
        }
} else {
        print "sorry, no results found";
};

Also, for:
=====
for($i=0; $i<5; $i++) {
        $a = mysql_result($res, $i); //This is line 30
=====

I'd suggest: while($a = mysql_fetch_array($res)) { 

Wouter


-----Original Message-----
From: Ryan A [mailto:[EMAIL PROTECTED] 
Sent: Sunday, September 14, 2003 11:45 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Program works only when there are records :-(

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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to