----- Original Message -----
From: "Christian Dechery"

> WHy PHP is not showing SQL syntax (or any) errors?
>
> I'm using Win98Me with Apache 1.3.12 and PHP 4.x.
>
> it works... if I run a correct query it runs normally, but if I go like:
>
> $query="selct nonexistingfield from nonexistingtable with all crazy
syntax";
> mysql_query($query);
>
> it doesn't tell me there's an error... in fact it doesn't show anything...
> why is that?

Because it's a pain to have error messages popping up all the time?
Here is what I do with every query I every write:


$query="yada yada";
$result=mysql_query($query, $connection);
if($result=="" || $result=="0")
{
 //if it is a page for my use, I print the error
// if it is a page for the general public, I email the
//error to myself, and print "There was a problem
//completing your request", or something like that.
 print "Error : ".mysql_error($connection)."<br>\n";
}
else
{
 while($row=mysql_fetch_row($result))
 {
  //do whatever you want to do with the data.
 }
}

I greatly prefer this to display "0 is not a mysql result index" for
everyone to see, if/when something goes wrong.

Anna


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to