![]() |
Redirect Incase of mySQL problem
If someone has posted something like this before, I couldn't find it.
What this does: It will redirect visitors to a static webpage of your choosing incase a connection to the mySQL server could not be established. Every so often, The SQL server of our host becomes unresponsive, usually only for a few minutes, but, it's still annoying to try and load the site and have it take forver then be finally be greeted with a lovely SQL error. So, now people can get a nice friendly error page instead. Feel free to modify and mess with it however you choose. UPDATED Trigunflame has provided a more elegant, sitewide solution that effectivly does the same exact thing. Installation: 1. open includes/db_mysql.php 2. find the code below in the connect() function Code:
if (!$this->link_id) Code:
// Redirect For SQL Server Down Just replace the url with where ever you want it to goto. I'm leaving the original file availible to download as it might be useful for other administrative purposes. |
I was looking for something like this... thanks for sharing ;)
|
Very nice, this is very usefull.
|
It doesn't take a good coder to make a great mod :)
|
Thank you very much.
One other note, if someone want's it, its not hard to modify the testcon.php file to take the database login settings from your vb config file. I just did it this way for flexibility and make it easier to test without causing site wide dissruption. |
Quote:
|
A better solution that will work on any page.
1. open includes/db_mysql.php 2. find the code below in the connect() function Code:
if (!$this->link_id) Code:
// Redirect For SQL Server Down All of the methods in the above posts's are redundant as they are trying to establish a "second" db connection. All that is going to do is slow down your pages on every load, and increase your mysql load by increasing its connections. |
Ah ha! new there was a better way. Curious though, would this method redirect on any kind of SQL issue such as conneciton limit reached (server side, not though VB), or any other failure to connect to the server and not just on an outright connection failure?
|
My method, or his?
|
His, Just wasn't sure what all errors it covered. I know that the method I put up pretty much covered all the bases incase of any kind of issue, just wasn't sure if the same was true with Trigunflames.
|
Quote:
Not only that.. its issuing a second connection attempt, effectively doubling your total mysql connections... The small lil mod I posted however, deals with it at the connection source inside of db_mysql. Thus every page, regardless if a connection cannot be established you are re-directed to the target location. Modify your main post btw with the snippet I posted for peoples future reference. |
Quote:
|
Thanks Trigunflame
/me udpates |
Anyone every seen a variation of this that send a text message or email to you if the db is not connectable?
|
Quote:
|
nice addon.. thanks
|
This looks good but how will members know theres a problem if they auto get forwarded to a new site?
|
you can forward them to a page instead, saying the site will be back in a bit or something like that,
|
Quote:
Server Down Message |
|
All times are GMT. The time now is 04:44 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|