0

I have several php errors that appear on the page as: Notice: Undefined index I have /etc/php/5.6/fpm/php.ini with display_errors = Off

When I set the value to On, I find even more errors on the page.

My htaccess file is empty and vHost conf is :

<VirtualHost *:80>
        ServerName website1.tld
        DocumentRoot /home/website1

        ErrorLog /var/log/sites/ website1_error_log
        CustomLog /var/log/sites/ website1_access_log combined

        DirectoryIndex index.php index.html index.htm index.php4 index.php5

        <Directory /home/website1>
                Options -Indexes +FollowSymLinks
                AllowOverride All
                Require all granted
        </Directory>
        <FilesMatch \.php$>
                SetHandler "proxy:unix:/var/run/php/php5.6-fpm.sock|fcgi://localhost/"
        </FilesMatch>
        RewriteEngine on
</VirtualHost>

Thank's

mbyou
  • 104
  • 1
  • 7
  • 1
    Surely the answer is to fix the errors then rather than suppress them. – Nigel Ren Dec 29 '18 at 12:43
  • 1
    Then please show the code where the errors occur. Do not hide the errors, solve them! – Jeff Dec 29 '18 at 12:43
  • It's a big production website and I can not correct thousands php errors. On the old server, errors are not displayed – mbyou Dec 29 '18 at 12:46
  • Have you changed php version? _"I can not correct thousands php errors"_ - how would you know the website is working as intended then? – Jeff Dec 29 '18 at 12:48
  • The website work with the same php version on debian v 6 and apache2. The new server is a Debian v 9 and apache 2.4.25. It’s not fpm ? – mbyou Dec 29 '18 at 12:50
  • Your website probably overrides `display_errors` with an `ini_set` call somewhere. – Jeto Dec 29 '18 at 13:07
  • @NigelRen Setting `display_errors` to off doesn't suppress the errors though, they'll still be logged as long as `error_reporting` (and/or `log_errors`) is not disabled as well. Hiding errors from the output is actually good practice on a production website. – Jeto Dec 29 '18 at 13:09
  • 1
    @Jeto - errors such as failing to allocate a resource or failure in connecting to some API are genuine errors which should be logged and investigated - I can understand that. But `Notice: Undefined index` messages are sloppy coding and potential indicators that the quality of code is generally suspect. – Nigel Ren Dec 29 '18 at 13:13
  • @NigelRen Yeah I'm simply saying, you can still view them in the log files, so it doesn't make them disappear. You can fix them by looking at the logs, though it's obviously not as practical as viewing them directly (which is encouraged during development). – Jeto Dec 29 '18 at 13:17
  • @Jeto - The quality of the code is not good and there are many many errors on all pages. on the old server, the mysql query worked correctly. now the error that often comes is: 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1' – mbyou Dec 29 '18 at 13:27
  • @M.Bou Notices are a thing, but SQL errors are gonna be an issue. I doubt your website can function properly with database errors. – Jeto Dec 29 '18 at 13:31
  • @Jeto - Exactly, but I doubt that mysql issues are related to encoding – mbyou Dec 29 '18 at 13:35

1 Answers1

1

You don't have to change anything in this /etc/php/5.6/fpm/php.ini. You can put error_reporting(0) at the top of your application/file.

<?php
// Turn off error reporting
error_reporting(0);
Kunal
  • 603
  • 4
  • 13