How can I suppress PHP error messages?

  • ming6655
  • Born
  • Born
  • ming6655
  • Posts: 1

Post 3+ Months Ago

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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

:wha:

I guess I am not following...
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

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.)
  • RichB
  • Guru
  • Guru
  • User avatar
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

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
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

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.
  • RichB
  • Guru
  • Guru
  • User avatar
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

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.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Thanks. Makes sense. Noted for future reference.
  • 3dmk
  • Newbie
  • Newbie
  • 3dmk
  • Posts: 12
  • Loc: Tucson, AZ, USA

Post 3+ Months Ago

The best way to suppress errors is to fix them. ;)
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

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
  • Posts: 526
  • Loc: St. John's, Newfoundland, Canada

Post 3+ Months Ago

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 62 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.