Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Revert to HTML ??? 1

Status
Not open for further replies.

kwkride

MIS
Sep 4, 2001
2
US
I'm using a free host for my website.
It's one that I build for a non-profit organization.
Several times a month there are times when you can't access my website because there are too many connections to their MySQL database. Is there some way that I could set up my site to go to an html version when this happens instead of giving the user a criptic error mesage?
 
in such cases the answer is to uprgade the computer. Ion Filipski
1c.bmp


filipski@excite.com
 
Yes, its fairly easy, actually. Maybe you are using mysql_connect(hostname,username,password) in its most simple form.

The preferred method when debugging is:

Code:
mysql_connect("hostname","username","password") or die(mysql_error());

This outputs the actual MySQL error message if a database connection fails. For your purposes, you can easily change that to something like:

Code:
mysql_connect("hostname","username","password") or die(error_handler());

Then you just create a function called "error_handler()" which redirects the user to a static HTML page if the database connection fails. Or, if you want it to be a little more sophisticated, just instruct your error_handling function to include() the appropriate block of HTML code from an outside file. This way, your users stay on the same page, having a seamless experience, without knowing that anything has gone wrong.
 
Thanks for the info, I really appreciate it.

I know that moving the site to a better host is the real answer, but they don't want to spend any money . . . .
 
It is also possible to make hard html copies every now and the of ure php pages, i dunno if this is php sided or serversided. But maybe the provider supports it. In that way u can display ure pages without using the mysql db, and if u refresh the pages every hour its up-to-date and also much faster, cause u will parse pure html to the client with no database or script action. mcvdmvs
-- "It never hurts to help" -- Eek the Cat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top