Re: Help with displaying rest of page after MySQL error
| From: | Stuart J. Browne | Date: | Sat, 17 Mar 2001 02:58:56 +0000 |
| Subject: | Re: Help with displaying rest of page after MySQL error | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-7558@lists.php.net to get a copy of this message | ||
> My first line of PHP code (embedded in HTML) has:
>
> $db = mysql_connect("x","y","z") or
> die("saysomethinghere");
>
> If I have a connection problem, it does print the
> "die" message and the connection error, but it also
> stops the page right there: no more HTML is displayed.
Well, you've mentioned your problem right here. 'or die (
"saysomethinghere" );'. Die meaing just that. "Die". Don't process
anything further.
> I know about suppressing the error message with "@"
> but this wouldn't seem to help this problem.
Try something like:
$db = mysql_connect("X", "Y", "Z");
$db_error = mysql_errno();
if ($db_error <> 0) {
print "Error conencting to the database";
$db_error = 1;
} else {
# Do the rest of your MySQL Queries etc. here
# or do checks to make sure $db_error is 0 prior
# to doing any...
}
hope this helps, or atleast points you in the right direction for
resolution.
bkx