469,352 Members | 1,694 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

is there anyway to hide php error messages ?

Is there anyway to hide php error messages? Because i have in my php code error but it redirecting after 1 sec and shows my hosting path and php error number, but this error doesn't effect anything.
Dec 10 '09 #1
14 4803
Dheeraj Joshi
1,123 Expert 1GB
Are you doing this in your code?

Expand|Select|Wrap|Line Numbers
  1. ini_set("display_errors", 1); 
  2.  
Regards
Dheeraj Joshi
Dec 10 '09 #2
Thanks Mr Dheeraj Joshi , you helped me alot, it's solved, it was great really ,
Dec 10 '09 #3
Dormilich
8,652 Expert Mod 8TB
it is always better to fix any errors that occur. as already mentioned, you can suppress the display of error messages, but this will get you in trouble, if there is a critical error appearing. additionally, you can catch any ‘error’ below E_ERROR level (i.e. warnings, notices and user defined errors) yourself and preventing them to show up.
Dec 10 '09 #4
Dheeraj Joshi
1,123 Expert 1GB
I will go with Dormlich's suggestion.

Its always good to fix all errors and warning in the code... You just can't predict that the error throwing situation can not occur..... Anyways try to fix the bug.

Regards
Dheeraj Joshi
Dec 10 '09 #5
Thanks Guys for replies

i fixed the error but i'm still putting ini_set("display_errors", 1);
in my code just to protect hosting path for any error , is this can make any problem ?
Dec 10 '09 #6
Dormilich
8,652 Expert Mod 8TB
of course, you won’t notice any new errors unless you catch the errors (as possible) beforehand. see also Exceptions*, Error Handling and set_error_handler()

* - I’d always prefer Exceptions over User Defined Errors
Dec 10 '09 #7
Thanks Mr Dormilich, your reply was useful
Dec 10 '09 #8
kovik
1,044 Expert 1GB
ini_set() is a function that alters the settings of your php.ini file for the rest of your script. php.ini is a file that is read and parsed by your server. As such, your server receives all errors from PHP that php.ini sets. This is governed by the "error_reporting" flags, not the "display_errors" flag.

In other words, even if you don't display the errors, the errors are still saved. In Apache, the error messages are in the apache/logs/errors.log file, in the order in which the occurred (ascending IIRC).
Dec 11 '09 #9
Hi Mr Kovik , Thanks for replay
i was asking for code just to hide the error messages from users because that can show my hosting path
but is the file logs/errors.log can be accessed by anyone else or just me and hosting ?
Dec 11 '09 #10
Dormilich
8,652 Expert Mod 8TB
just you and hosting. though a decent error catching system can react immediately (e.g. sending a mail), while you have to access the error.log yourself.
Dec 11 '09 #11
kovik
1,044 Expert 1GB
Well, depending on the capability of your host, it's possible that they are the only ones with access. Servers are capable of creating one central errors.log for the entire shared server, or for developing individual errors.log files for each sect.

When looking for a good host, this is normally one of the things that I check. I also check for proper PHP settings (i.e. magic_quotes), flexible database table naming (i.e. no automatic prefix), and that they have the newest versions of Apache, PHP, and MySQL installed. Normally, a lack of any of these attributes implies that the server is run by amateurs who are more concerned about themselves than their users.

But, I digress. :P
Dec 11 '09 #12
Thanks to Mr Dormilich and Mr Kovik for replies

is there a way to check if the hosting is using central or individual errors.log ?
Dec 11 '09 #13
kovik
1,044 Expert 1GB
If you have FTP access (which you *should*), then look in the file structure. There's a folder that is your root folder, where your main index page should exist. If you have access to the folder above your root folder, there is likely a "logs" folder in which you will find your errors.log file.

If not, then look through all of the folders in your root folder that you did not explicitly create. If you do happen to find your errors.log file in one of these folders, I suggest that you use a .htaccess file to block access to that folder (unless the server already blocks it). Otherwise, it may be open to the public eye.
Dec 11 '09 #14
Thanks Dear Kovik
but i logged in FTP but i just see all my folders and there's no other folders or files
i'm using godaddy hosting
Dec 13 '09 #15

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by lkrubner | last post: by
10 posts views Thread by Brian Conway | last post: by
2 posts views Thread by FutureShock | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.