Page 1 of 1

Warning: Supplied argument is not a valid

Posted: Mon Dec 16, 2002 10:12 am
by DRTechie
I am getting an error message on a code someone supplied for me and I can't figure what's wrong with it. Maybe a fresh pair of eyes can spot where the error is coming from. Thanks.
Warning: Supplied argument is not a valid MySQL result resource in /var/www/html/circuit_report.php on line 18

Code: Select all

// sites that have at least 2 primary type circuits
$sql = "SELECT sc.site_id, COUNT(sc.site_id) AS total_circuits
FROM site s, circuits c, site_circuit sc
WHERE type = 'primary' AND
sc.record_id = c.record_id AND sc.site_id = s.site_id 
GROUP BY sc.site_id
HAVING total_circuits >= 2";

$site_result = mysql_query($sql);

while ($site_array = mysql_fetch_array($site_result))
{
//select details for site_id's returned in first query 
$site_id = $site_array['site_id'];
$sql = "SELECT sc.ckt_id, sc.site_id,  s.sitename, s.address1 
FROM site_circuit sc, circuits c, site s 
WHERE type = 'primary' AND sc.site_id = '$site_id' 
AND sc.record_id = c.record_id 
AND sc.site_id = s.site_id";

$detail_result = mysql_query($sql);
while ($detail_array = mysql_fetch_array($detail_result))
{ 
// get details of each site
// repeated rows for each row in relation
echo $site_detail['sitename'];
}
}
LINE 18 is
while ($site_array = mysql_fetch_array($site_result))

Posted: Mon Dec 16, 2002 10:45 am
by kcomer
it's probobly your sql sommand. Have you printed $qry to the screen and ran it straight into the db to see what error it gives. I would bet this is the problem.

Posted: Mon Dec 16, 2002 10:49 am
by DRTechie
Actually I got the querys working. I was just missing a comma in the first one. I also ran both querys through command line and they work fine. My only problem now is that when I open the script through my browser it only displays a blank page. I am a total newbie at this stuff so any help would be greatly appreciated.