supplied argument is not a valid
| From: | John Taylor-Johnston | Date: | Sat, 25 Sep 2004 05:01:13 +0000 |
| Subject: | supplied argument is not a valid | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-197810@lists.php.net to get a copy of this message | ||
Hi,
My question: can I open $table2 within $table1 - I thought so.
I thought I had this set up correctly. Sorry to throw all these lines of code at you. But I need to
situate the error for someone to see plainly what I'm doing.
I'm getting this error:
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in
/home/users/q/qx04t9mu/www/English/directory4.php on line 101
I'm using two tables: $table_glq & $table_officers
I'm trying to link to a second table with a first. This should work, but does not!
My error is here:
line 101> while ($mydata2 = mysql_fetch_object($news2))
---------snip------------
######################################################
$sql = 'select * from '.$db.'.'.$table_glq.' order by district,number
asc';
$news = mysql_query($sql); //desc => z-a
$previous_district = "";
while ($mydata = mysql_fetch_object($news))
{
if ($previous_district != $mydata->district) {
$previous_district = $mydata->district;
echo "<hr size=1><h2>$mydata->district</h2>\n";
#$sql2 = 'select * from '.$db.'.'.$table_Officers.' where
district=$mydata->district';
$sql2 = "select * from ".$db.".".$table_Officers."where
district='" . $mydata->district. "'";
$news2 = mysql_query($sql2); //desc => z-a
while ($mydata2 = mysql_fetch_object($news2))
{
echo "<li>$mydata2->Name</li>\n";
echo "<li>$mydata2->biography</li>\n";
}
}#end of if
echo "<h3>$mydata->group No.$mydata->number</h3>\n";
echo "Meets: $mydata->meetingtime</small>";
}#end of while
############################################################
Both versions of $sql2 work, by the way - if that helps.
John