Re: when mysql is down

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 17, 2008 at 12:07 PM, Stut <stuttle@xxxxxxxxx> wrote:
> On 17 Oct 2008, at 16:52, Rick Pasotto wrote:
>>
>> Today my hosting company took down the mysql server for about 1/2 hour.
>> As a result some php errors displayed.
>
> Firstly if they didn't tell you it was going to happen then I suggest you
> change host. Unless it was an emergency, but even then they should have
> contacted you as soon as they knew it was going to happen.
>
>> All of my pages have a random quote from a mysql table. If it's not
>> available it's really not a big deal. However, some of the pages depend
>> entirely on data from the database.
>>
>> What's the best way to handle this? If the mysql is required should I
>> redirect to the front page (which doesn't need mysql except for the
>> quote) or show a blank (or error message) content area (navigation would
>> still be available as it's the same on all pages)?
>>
>> The quote is from an include file. What's the best way to output nothing
>> if the mysql connection fails?
>>
>> I realize these are probably elementary questions but any advice would
>> be appreciated.
>
> Production websites should have display_errors off in php.ini. This will
> prevent the site from displaying PHP errors at all. PHP errors can reveal
> more about your site than you want to share and could potentially reveal
> holes.
>
> To answer your question you simply need to check the return value from the
> connection function. It sounds like you're not doing this and just going
> ahead and trying to use the connection regardless. The best way to avoid
> errors is to not do stuff that will cause them.
>
> Ideally if you cannot create the page that was requested you should return a
> 503 HTTP error, a message indicating a temporary problem and end the script
> there. Not only does this inform your users that the problem is temporary it
> also indicates to search engines that they should not index this page right
> now but that the URL is still valid.
>
> -Stut
>
> --
> http://stut.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Okay I just replaced 500 with 503 in my stuff.  Thanks for the tip.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux