is there anyway to hide php error messages ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fuchsia555
    New Member
    • Dec 2009
    • 56

    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.
    Last edited by Niheel; Dec 10 '09, 11:45 PM. Reason: grammar, ease of reading
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    Are you doing this in your code?

    Code:
    ini_set("display_errors", 1);
    Regards
    Dheeraj Joshi

    Comment

    • fuchsia555
      New Member
      • Dec 2009
      • 56

      #3
      Thanks Mr Dheeraj Joshi , you helped me alot, it's solved, it was great really ,

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        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.

        Comment

        • Dheeraj Joshi
          Recognized Expert Top Contributor
          • Jul 2009
          • 1129

          #5
          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

          Comment

          • fuchsia555
            New Member
            • Dec 2009
            • 56

            #6
            Thanks Guys for replies

            i fixed the error but i'm still putting ini_set("displa y_errors", 1);
            in my code just to protect hosting path for any error , is this can make any problem ?

            Comment

            • Dormilich
              Recognized Expert Expert
              • Aug 2008
              • 8694

              #7
              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_handl er()

              * - I’d always prefer Exceptions over User Defined Errors

              Comment

              • fuchsia555
                New Member
                • Dec 2009
                • 56

                #8
                Thanks Mr Dormilich, your reply was useful
                Last edited by Dormilich; Dec 10 '09, 03:33 PM. Reason: spell correction

                Comment

                • kovik
                  Recognized Expert Top Contributor
                  • Jun 2007
                  • 1044

                  #9
                  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_reportin g" 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).

                  Comment

                  • fuchsia555
                    New Member
                    • Dec 2009
                    • 56

                    #10
                    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 ?

                    Comment

                    • Dormilich
                      Recognized Expert Expert
                      • Aug 2008
                      • 8694

                      #11
                      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.

                      Comment

                      • kovik
                        Recognized Expert Top Contributor
                        • Jun 2007
                        • 1044

                        #12
                        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

                        Comment

                        • fuchsia555
                          New Member
                          • Dec 2009
                          • 56

                          #13
                          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 ?

                          Comment

                          • kovik
                            Recognized Expert Top Contributor
                            • Jun 2007
                            • 1044

                            #14
                            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.

                            Comment

                            • fuchsia555
                              New Member
                              • Dec 2009
                              • 56

                              #15
                              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

                              Comment

                              Working...