Display Errors Local / Master Value - php

i'm about to set up my first own VPS for my website. cPanel is installed, PHP and MySQL are up to date.
I get some "Strict Errors" on my website, the errors are not a bad thing, but it looks not so nice of course. In my php.ini display_errors is set to off, of course. Because i use cPanel, i can upload a php.ini in the root folder of my user account. This works and should be the local value. But the errors still persist. Now, i got myself a php file with <? phpinfo(); ?> and uploaded it to the root of my user folder. Looks like this. You can see, display_errors local and master value are off. Now, when i go to my Joomla System Information and look into the php information, i see this. Here is the local value on. But why?! There is nothing in the .htaccess and when i write something in there like php_flag display_errors off it breaks my page with 500 Internal Server Error. Of course, i cleared the cache of Joomla and i tried to find another string with "display_errors", but no luck so far.

Related

WordPress: PHP warnings and notices shown even with WP_DEBUG and WP_DEBUG_DISPLAY consts set to false

I've tried setting WP_DEBUG and WP_DEBUG_DISPLAY to false. After that, I've tried following in wp-config:
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
Still, PHP warnings and notices are shown on the frontend. I've also checked with ini_get before and after setting ini vars, looks like it's properly set everything, but notices and warnings are still shown.
If I clone website locally or to different host, everything works properly, ie. notices and warnings are hidden. Is there anything else I could try?
This is not a wordpress issue but tied to your server setup and php configuration.
Option 1: Make sure error output is disabled on server side
If you have access to your hosting admin area (... maybe something like plesk or a custom admin ui): search for something like:
error reporting
php settings
php.ini
Usually you'll see some options like:
show only critical errors and omit notices
log errors to a log file
disable all error messages and logging
Nothing?
Contact the hosting provider's support (or web admin), where to set this configuration. (This should actually be default in every hosting environment – even with most basic shared hosting setups).
Option 2: Dirty Hacks/overridung
php-script
htaccess directives
2.1 If your theme has a global header template part/include like "header.php" that's included/required before any html output, you could add a php function like
<?php
error_reporting(0);
<?>
This should work pretty much everywhere – still a temporary solution. If you're using a regularly updated theme – this hack will be deleted after every update.
2.2 htaccess directive
Jeff Starr has elaborated on this approach
If you have access to a .htaccess file you might try to add these directives
# supress php errors
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_value docref_root 0
php_value docref_ext 0
Actually ... not a valid solution either.
.htaccess will only work if you're on an apache driven webserver (even then – based on your apache version, specific compiled version, configuration ... quite a lot of snippets just won't work).
Maybe your website isn't even hosted on an apache webserver but instead nginx or even IIS ... etc.
Before checking other options, you might check your current webserver/php setup by
uploading a test.php file with this content to your root dir
<?php phpinfo(); ?>
Delete this file after checking your setup. In particular interesting wether you're on apache or nginx etc.
Conclusion
Make sure to disable error handling on the server side. So stick with proper server configs and don't waste too much time with any hacks! (... we all need them now and then!)
You can check on your server setting and make error reporting off.May be it will works

Problems with moving site to new host

I have moved my php site to a new host but this is causing massive problems, namely with the require(mysqli_connect.php) which, ofcourse is to connect to the database. Any file that has this require does not load up, leaving just a blank page. These pages worked perfectly fine before switching and work fine if I comment out the require. Would the db not connecting cause this require to fail?
I haven't used php for 2 years+ now, so sorry if this is not enough detail, but not sure what more I can give.
Mysqli might not be installed on that server. Either ask the admin of the server to solve this problem, or if it is yours, check this out:
http://www.php.net/manual/en/mysqli.setup.php
Enable PHP error reporting to see what the error really is. In the script itself, before the require('mysqli_connect.php'):
error_reporting(E_ALL);
or in .htaccess file
php_flag display_errors on
php_value error_reporting E_ALL

The PHP error log has stopped working. It did work

It's been working for ages and stopped. I must be missing something obvious.
File /etc/php5/apache2/php.ini relevant settings are:
display_errors = On (I am not sure if this makes a difference)
log_errors = On
error_log = "/var/www/error_log.log"
In my code I have:
echo 'About to log';
error_log('An error');
I see "About to log" on the page, but nothing in the error log. How can I fix this?
Restart the Web server. Until you do php.ini changes are not considered.
Also, if you want to track PHP errors, you need to have track_errors=On and error_reporting=E_ALL, although that is not related with error_log calls. Also make sure that the error log file is writeable by the Web server user.
It ended up being permission issues. The file grew too big to open quickly, so I deleted and recreated it, but with read-only permissions.
I totally forgot I deleted it. What a pain.
In my php.ini file (XAMPP default), there was a second entry for error_log overriding the one that I had set.
So if the other answers do not work for you too, search again for multiple entries of the necessary settings.

Can't get PHP to report errors

I can't see any PHP errors. I have tried every trick I can find to turn error reporting on, but nothing works.
display_errors is on and error_logging is on, but when I view any page with an error, I get a blank page.
/var/log/php.log does not exist.
if I set a local logfile, Nothing gets created.
The file I have been testing with is
<?php
ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);
ini_set('error_log','script_errors.log');
ini_set('log_errors','On');
$a=
phpinfo();
?>
any other ideas?
You probably need to set it in .htaccess, httpd.conf or php.ini (depending on your server or hosting company). You most likely have a parse error, which means your script never gets to the point where it can turn on the error reporting.
Have you tried editing the actual ini file as opposed to trying to change it at runtime? You can also try using ini_get('display_errors'); to see if your change took effect. If neither of those work I would say your installation is either faulty or very restricted.
Run phpinfo() as the first thing in the script, before you try any of the ini_set options. If your host has those ini functions disabled/restricted, you'll most likely not ever get to phpinfo.
Does the userID the webserver's running under have write permissions in the directory you're running this script from? It could be failing to open your test log file and kill the script that way.
Once you get some phpinfo() output, you'll be able to see if/where PHP is logging errors. It could be going into the server's general error_log, or some other location entirely.
i solved this problem by my hosing website
cpanel-> php config ->display error on

PHP in linux (LAMP) is not displaying cause of errors when code fails? (Ubuntu)

I was a Windows user and used Wamp. Every time a PHP code failed, the browser would display something like this: error in line number xx.
I followed the installation of this tutorial and everything worked.
Now when code fail PHP just display a blank page.
Any sugestions?
(I'm using Ubuntu 10.04).
I know this is a old post, but I had the same problem and found out that after error_reporting, there is a option of display_errors, change it to On.
Old question, as Gurnarok noted, but still, here's the answer.
The standard LAMP server installation on Ubuntu does this. I simply call it "production" mode, i.e. your pages don't display errors (to your users) when your site goes live. I rather like that it does this, but I was confused at first, as well.
Instead of editing my php.ini file to go into "development" mode, I simply place this at the top of my PHP files (or, PHP file, in my case, since I usually pass everything through index.php):
ini_set('display_errors', true);
error_reporting(E_ALL ^ E_NOTICE);
So, the reason why error_reporting by itself isn't doing the trick, is most likely because display_errors isn't set to true in your php.ini file. The code above should take care of that.
I prefer to exclude the PHP "Notice" notification, such as notifications about non-existent array keys (the most common Notice, in my case), but you're perfectly welcome to simply change this to error_reporting(E_ALL);
Of course, you can set these variables in the php.ini file, I simply prefer it this way, so that when the site goes live, I simply remove those two lines from index.php and I'm in no danger of errors showing up to my users.
Find php.ini under /etc/php5/apache2/ and set the value of error_reporting to E_ALL. Like:
error_reporting = E_ALL
Or alternatively check error.log if your virtual host is providing one.
Thanks Phil your answer got me thinking and I finally managed to fix an issue thats been bugging me for weeks where my PHP install wasn't displaying errors in the HTML page at all (except sometimes a notice message but never any syntax errors etc). Even though I had all other error settings set to "on" and log_errors set to on and a filename for the log only notices were getting logged to the log file but never any syntax errors. Not very useful on a development server :)
Thought I would post my findings here in the hope that this info can help someone else with the same issue as Google wasn't very helpful with fixing the issue.
In older versions of PHP before PHP 5 I used to always have my error reporting setting in PHP ini set to "E_ALL & E_NOTICE" on my development servers. In later versions of PHP (well with my Ubuntu Oneric install anyways) using this setting seems to cause no output to be displayed at all in the HTML page regardless of the other php.ini settings (like display_errors = on, etc). Setting the values on the fly in a PHP page didnt help either as it seems the php.ini value overrides the per file setting.
I changed the error_reporting value to "E_ALL" only and now it displays syntax errors. The setting recommended in php.ini for a development server (E_ALL | E_STRICT) doesnt work for me either so thanks a lot. +1 to you :)

Categories