How can I suppress PHP error messages?

  • ming6655
  • Born
  • Born
  • No Avatar
  • Joined: Nov 30, 2003
  • Posts: 1
  • Status: Offline

Post November 30th, 2003, 4:28 am

How can I suppress error message from PHP program when someone visits my website?

PHP 4

Thanks,


[url]actel.jp/kddi.com[/url]
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post November 30th, 2003, 4:28 am

  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Joined: Jun 15, 2003
  • Posts: 4583
  • Loc: Maryland
  • Status: Offline

Post November 30th, 2003, 5:26 pm

:wha:

I guess I am not following...
Pixel Acres V2
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23403
  • Loc: Woodbridge VA
  • Status: Offline

Post November 30th, 2003, 6:17 pm

I think he's getting a 404 page not found error.

ming6655, if the page that you are refering to is the one you are using in your signature then the page isn't where it's supposed to be or the URL you're trying to use to get to it is screwed up. Truthfully I've never seen a URL like the one you have in your signature. We need some more details to help. (PS. -- in order for your signature URL to work correctly here, you have to enable BBCode in your profile.)
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • RichB
  • Guru
  • Guru
  • User avatar
  • Joined: May 17, 2003
  • Posts: 1121
  • Loc: Boston
  • Status: Offline

Post November 30th, 2003, 6:47 pm

I think he means PHP error messages like:

Code: [ Select ]
Warning: Wrong parameter count for fopen() in c:\program files\apache group\apache\htdocs\test.php on line 3


To suppress all errors add error_reporting(0); to your code.

There are several variations on this such as reporting only fatal errors etc. See this link for more info.

http://ist.marshall.edu/ist263/l27.html
Free Programming Resources
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23403
  • Loc: Woodbridge VA
  • Status: Offline

Post November 30th, 2003, 7:03 pm

RichB, I've always believed you were good, but I would love to know how you deciphered that out of the information given in the original post. I did figure out that his page was linked in the www graphic, not the signature one, but I can't read a word that page.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • RichB
  • Guru
  • Guru
  • User avatar
  • Joined: May 17, 2003
  • Posts: 1121
  • Loc: Boston
  • Status: Offline

Post November 30th, 2003, 7:26 pm

I didn't actually try to view the page until just now, but I guessed that was what he meant because it's something that's come up for me recently as I have php support with my new host. Until now I've been using it locally, so it wasn't really an issue.

I was concerned that php error messages are sometimes a little too descriptive to be seen by visitors, so I went looking for a way to suppress them. The link I gave has info on setting error reporting levels and writing to the php error log, although so far I've only tried suppressing them by setting the error level to zero.
Free Programming Resources
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23403
  • Loc: Woodbridge VA
  • Status: Offline

Post November 30th, 2003, 7:52 pm

Thanks. Makes sense. Noted for future reference.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • 3dmk
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jan 21, 2004
  • Posts: 12
  • Loc: Tucson, AZ, USA
  • Status: Offline

Post January 22nd, 2004, 12:08 pm

The best way to suppress errors is to fix them. ;)
  • Axe
  • Genius
  • Genius
  • User avatar
  • Joined: Jan 07, 2004
  • Posts: 5744
  • Loc: Sub-level 28
  • Status: Offline

Post January 22nd, 2004, 1:10 pm

Exactly! :)

As far as I'm concerned, PHP's errors (like most programming languages) are too Cryptic ;)

Ok, so I've got an error on line 1725... Then, why do I have to fix it on line 6? ;)
  • rjmthezonenet
  • Expert
  • Expert
  • User avatar
  • Joined: Jan 14, 2004
  • Posts: 526
  • Loc: St. John's, Newfoundland, Canada
  • Status: Offline

Post January 23rd, 2004, 8:31 am

3dmk wrote:
The best way to suppress errors is to fix them. ;)


PHP may return errors because other components such as a file syste or database failed. The best you can do with your PHP code is anticipate all the failure points and write your own exceptions.

As for the original post...

grep your php.ini file for "error" and you'll find several occurances. Most importantly, you can set error_reporting = 0 in the ini file. This means you do not have to change your scripts, and are assured that no errors will be seen by the user.

Now its time to think about logging those errors to a file...

Post Information

  • Total Posts in this topic: 10 posts
  • Users browsing this forum: No registered users and 137 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.