![]() |
a question for php gurus
ok, so i needed to make a few very important pages in "php" on a few websites.
then something happens on the server, maybe mySQL can't connect or the mySQL datatbase gets corrupted somehow. and then this very important web page does not load. is there a general setting in php that makes it tolerant of failure? what i'm asking is---is there a way to configure it on the server so the php page will always load no matter what happens. any advice appreciated! |
wtf.
If my computer breaks can you make it still work with some setting? :1orglaugh |
Always back up!! back up!! back up!! Before :)
Permissions? |
for example, if there is a problem with hahahahahahahahahaha, a page can still function---the hahahahahahahahahaha may be wrong, but the page will load, it will say "done, error on page" etc in task bar.
sometimes when php fails the page won't load at all. that's what i'm trying to avoid. i'll bet someone here knows the answer for this. |
certainly, i have a backup.
the issue is, the pages involved are key pages in a website tour which need php for some trick autoupdating. and if something fails (like a failure at my host with their mySQL server) the darn page won't load. |
It depends on the functions you're using, you can suppress error output but some functions will end the script if they fail, others will just return the error message and try to continue.
|
Quote:
ok Rorschach, i knew there were some smart guys here :) is there a "general" setting that you would change to build in "fault tolerance"? |
I'm no PHP guru but I don't think so, AFAIK it's more an issue of each individual function. For example, IIRC, include() will return an error if it fails and try to continue, whereas require() will end the execution of the script if it fails. There are options in php.ini that you can use to determine the level of error reporting, and you can use @ in front of function names to suppress errors, but there's nothing that's going to change the way a function fundamentally works short of rewriting it.
One way to get around fatal errors is to use if/else statements - eg in psuedo code if(function()) { do this; } else { print error; } Maybe someone else can shed more light on an answer. |
Quote:
Rorschach, i appreciate your thoughts on this. but i don't want to re-write the script i'm using. it a commerically avail script (autolinkspro) that i'm using to automatically update (every 15 minutes in this case) certain images on a tour which contain a link to a sample video. the reason i use this instead of a random js is because it prevents the surfer from just refreshing the page and downloading the next video sample---it's a bandwidth saver. the problem here is that this is a key page in the tour. a couple times in the last month something has happened at my host (got errors of "can't connect to mySQL server") which caused this important page to not load---which then completely destroys the tour. and these sorts of things always seem to happen at 3am and you don't notice something is wrong until you look at your sales figures and wonder why you aren't getting signups on the domain, and then you go check it and the darn page is loading. so i'm looking for a way to tweak the general php settings on the server, so if php has problems, at least the page will still load even if the php parts of the page won't load. |
really simple
just end every mysql query with the mysql_error() routine and instruct your script to kill everything or redirect to another page in case of an error.. http://php.net/mysql_eror |
Also, by pre-pending the "@" symbol to php specific functions it will supress errors...such as @include or @mysql_connect(...)
Just my two cents... -Mr. T |
gentleman, thank you all.
but, would it not be simpler to just alter the general php settings on the server? (as opposed to altering the script) for example, just take a look at "mydomain.com/phpinfo.php" and make a change to the general php config to build in some fault tolerance. i cannot solve the problem this way? |
If you want a really easy solution, put all your images into a directory named by date, and call the image names dynamically according to what day it is.
|
Quote:
well that sounds good, but what i'm doing is more complicated. this autolinks script does some neat things, it allows me to show a dynamically changed image, with it's unique description, which links to a unique html sales page, which links to a unique "sample video" every 15 minutes. this is the house of cards i'm trying to keep from falling, and it only falls apart when there is a php error. |
All times are GMT -7. The time now is 01:13 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123