Can someone tell me the best way to stop a php script from throwing out error messages if it can't work. I'm using a web fetching script which occasionally throws errors due to changes that are out of my control - ie changes on the fetched site.
I've got a 'no headlines found' message which comes up if 'grab' fails, but it still throws error messages if something else is wrong.
I want a total block on all error messages if anything doesn't work.
<Edited by ChilliBoy on 12-15-2000 at 04:54 PM>
You can either put
at the top of your script which would be the easiest this turns off errors for the whole script even parse errors.
you an use an @ in front any function that you don't want errors to show
@$fp = fopen("someurl");
Putting a @ sign in front of the command should block the errors, say you wanna connect to a db, but don't want it to give you errors if it fails, you would use:
@mysql_connect($site, $username, $password)
This (error_reporting(0);) looks like the baby!
I can the (0) be changed to what you want??
<Edited by ChilliBoy on 12-15-2000 at 06:11 PM>
Just be careful because like i said if you have a parse error it won't show it to you
Just edited my post while you where posting:
Can the (0) be changed to what you want??
I'm not to worried about the errors not being reported. If the script is working OK initially and then things aren't coming up, I can quick remove the 'no error tag' to find out whats wrong. I was testing things out when it threw out an error and it messed up the whole page. - Can't have that happening.
Yes the default error reporting is 15 which means
1 = Fatal Errors
2 = Warnings
4 = Parse Errors
8 = Notices
So setting t0 7 would be turn on errors for Fatal Errors, Warnings and Parse Errors
3 would be Fatal Errors and Warnings
1 would just be fatala errors