note 104075 deleted from language.operators.errorcontrol by danbrown
| From: | danbrown@php.net | Date: | Mon, 23 May 2011 15:13:02 +0000 |
| Subject: | note 104075 deleted from language.operators.errorcontrol by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-179977@lists.php.net to get a copy of this message | ||
Note Submitter: pgreviews at gmail dot com
----
Using this, you can catch MySQL errors VERY easily, like so:
<?php
//For example, if you were looping through a result-set:
while (@$needle=mysql_fetch_array($haystack) or die("MySQL returned an error. The error was
suppressed, and this message was added instead.")) {
...
}
?>
This is very useful, for example, instead of even showing an error, just stick a
header("Location: ".$_SERVER['HTTP_REFERER']); in it, and the user will be
redirected back to where they came from!