Quote:
|
Originally Posted by Calvin
Ok we just had one of those MySQL errors. The image thing worked (the error.gif) was displayed, but it slowed down the website a bit.
Here is the code used:
PHP Code:
mysql_connect($hostname,$username,$password); if(mysql_error() == "") { // Display the right image } elseif (mysql_error() != "") { header("Location: " . "http://franklin.f2o.org/topsite/error.gif" . ""); }
It seems to be taking alot of time trying to connect... is there a faster way to try connect, and VERY fast say if there is a error or not?
hmmm how about :
PHP Code:
$link = @mysql_connect($hostname,$username,$password); if (!$link) { header("Location: " . "http://franklin.f2o.org/topsite/error.gif" . ""); }
Would that speed it up, as far as testing goes?
|
It would be slightly faster but only by a little bit, there should be no reason that a small if statement should make it bigger, also you may want to use function die() after you complete the header() function like this, to speed up the reloading of the image to the image file.
PHP Code:
$link = @mysql_connect($hostname,$username,$password);
if (!$link)
{
header("Location: " . "http://franklin.f2o.org/topsite/error.gif" . "");
die();
}