Function Problem (Long-ish)
| From: | Dave Carrera | Date: | Tue, 13 Jan 2004 12:34:33 +0000 |
| Subject: | Function Problem (Long-ish) | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-174424@lists.php.net to get a copy of this message | ||
Hi List,
I have a self-made function that uses a MySql statement something like this:
Function MyFunc(){
sql = mysql_query("select * from table where somefield=\"somevar\""){
while(blah blah){
$var ="blah blah";
}
}
return $blah;
}
This works ok but if I add a bit to the sql then I get a Warning:
mysql_fetch_array(): supplied argument is not a valid MySQL result resource
in error, so if I add:
Function MyFunc(){
sql = mysql_query("select *, count(id) as cnt from table where
somefield=\"somevar\""){
while(blah blah){
$var ="blah blah";
}
}
return $blah;
}
I get the error.
But this works:
Function MyFunc(){
sql = mysql_query("select count(id) as cnt, sum(numfield) as total from
table where somefield=\"somevar\""){
while(blah blah){
$var ="blah blah";
}
}
return $blah;
}
My Question is Why ?
Any help is a appreciated and I thank you fully in advance.
Dave C
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.560 / Virus Database: 352 - Release Date: 08/01/2004