Re: Function Problem (Long-ish)
| From: | David Robley | Date: | Tue, 13 Jan 2004 12:48:04 +0000 |
| Subject: | Re: Function Problem (Long-ish) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-174428@lists.php.net to get a copy of this message | ||
In article <003e01c3d9d1$9a14c2f0$0301a8c0@daveslaptop>, dave@ephgroup.com
says...
> 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.
Bit hard without seeing your actual code; however if you were to use
mysql_error() after your call to the database it would probably return you
a useful error message.
Cheers
--
Quod subigo farinam
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet?