Re: warning
| From: | tony | Date: | Tue, 17 Oct 2000 12:34:49 +0000 |
| Subject: | Re: warning | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-20620@lists.php.net to get a copy of this message | ||
Thanks for the FAST reply, everyone.
What was I thinking? It's giving the warning, and I was
arguing that there wasn't an error.. I found the error in
the function that I wrote that executed the SQL query.
Tony
----- Original Message -----
From: "Phil Driscoll" <phil@dialsolutions.co.uk>
To: "tony" <tony@uickarate.com>; <php-general@lists.php.net>
Sent: Tuesday, October 17, 2000 9:25 AM
Subject: Re: [PHP] warning
> This is the old favourite caused by you not checking that the mysql_query
> returned a valid result.
>
> You need to handle the case where the mysql_query call returns 0
> something along the lines of:
>
> $results = mysql_query($sql);
> if($results)
> {
> $array = mysql_fetch_rows($results);
> }
> else
> {
> echo('error: mysql query went wrong');
> ...deal with it/get extra error information etc
> }
>
> If you can't carry on if the query fails you can use 'OR die' to bomb out:
>
> e.g.
> $results = mysql_query($sql) OR die('error: mysql query went wrong');
>
> Cheers
> --
> Phil Driscoll
> Dial Solutions
> +44 (0)113 294 5112
> http://www.dialsolutions.com
> http://www.dtonline.org
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>