Re: PHP4 and mysql_fetch_array() - one more try
| From: | Michael Dearman | Date: | Thu, 02 Nov 2000 17:21:46 +0000 |
| Subject: | Re: PHP4 and mysql_fetch_array() - one more try | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-4146@lists.php.net to get a copy of this message | ||
Phil Driscoll wrote:
>
~~~~
> Please re-read the email I sent to you and the list yesterday.
> Your mysql_db_query is returning 0, meaning that some kind of error occurred
> (NOT that no rows were returned!).
> mysql_error() will probably tell you what the error was.
> You cannot safely use the return from mysql_db_query (or indeed many other
> functions) without first checking that it did not return an error.
>
> Cheers
> --
Well, I responded earlier, but it's not showing up. So this may be redundant if it
does.
I've just be using a die with mysql_error on the query
and an if check with mysql_num_rows.
(you didn't have a copyright so I'll just steal your example Phil ;-)
Shouldn't this catch most any most any problem?
$rs_result=mysql_db_query($db,"SELECT * FROM XX WHERE something=$yy",$connection)
or die ("Can not execute query: " . mysql_error);
if(mysql_num_rows($rs_result))
{
while($row_result=mysql_fetch_array($rs_result))
{
do_something();
}
}
else
{
echo('something went wrong - here's a clue: '.mysql_error());
}