Errors not displaying in PHP 5.3 - php

I recently upgraded to PHP 5.3.22 and now I'm getting WSODs whenever there are errors in my php code. I know I have display_errors disabled in php.ini, so I tried adding the following code to the top of my scripts to temporarily enable displaying errors on the screen for debugging.
error_reporting(E_ALL);
ini_set('display_errors', '1');
The above works if I have an undefined function but if I miss a semi-colon at the end of a line, it still displays a WSOD.
How can I get all errors to display on screen when I'm developing the scripts?

Enabling error reporting at run time like that fails to show fatals. You can enable it in your php.ini or add this to your htaccess to override it:
php_value display_errors 1

As the file cannot be parsed, setting the error level and display_errors inside the file is having no effect.
Set it in your php.ini

Related

Not displaying errors in php

I am debugging some errors in my PHP bus booking site. My issue is that I am not able to display errors. When I googled this issue it shows you can achieve it though php.ini. But unfortunately I haven't find any php.ini file .
Now the error is showing as
This page isn’t working
cableandmedia.com is currently unable to handle this request. HTTP
ERROR 500
On your all-pages/or-a-common-file which-is-included-in-each-file.
On top just after starting <?php add these two lines:-
error_reporting(E_ALL);
ini_set('display_errors',1);
If you have php.ini file then check these two variables:-
display_errors
error_reporting
Now change these variables values to:-
display_errors=ON
error_reporting=E_ALL
Now save the file and restart your server(important if you are working on localhost).And you have good to go.
Add this line to your php file. To debug
ini_set('display_errors', 1);
error_reporting(E_ALL);

I can't disable PHP errors

So what's going on is I tried
ini_set('display_errors', 'Off');
error_reporting(0);
Right below <?php, but this didn't seem to stop displaying them. So I went to the php.ini and went to display_errors and saw that it was set to Off. But it still showed.
So I went and did phpinfo() and display_errors along with display_startup_errors are both off. Also html_errors is off. I'm not sure if this will help, but it says error_reporting is set to -10241. Any ideas?
Do not change the value of error reporting to solve the issue. If display_errors is off, errors are not display independently of the error_reporting setting. This way you will not display errors but you can still log them.
The following should work:
ini_set('display_errors', 'Off');
If it doesn't work it could be that your server configuration does not allow you to change settings from PHP scripts. ini_set() returns FALSE on failure. So first of all you should check what value that call is returning. Make sure that ini_set is not listed among disabled PHP functions (disable_functions in php.ini).
If you are asking yourself why errors are still being displayed even if in php.ini the display_errors is Off, you can check the actual value of display_errors during the script execution:
ini_get('display_errors')
Pemember that PHP settings could be changed also in Apache host configuration and in .htaccess files. So check if you have an htacces that enables display_errors. Something like this:
php_flag display_errors on
Try to use:
ini_set('display_errors', 0);
ini_set('display_errors', false);
You don't describe what the errors are, so it's possible that your web server (Apache, nginx, etc) are what's throwing the error and not PHP.
If it is PHP, ensure that you're editing the correct php.ini as identified in your phpinfo.php. Remember that if you edit the php.ini, you will need to restart your PHP process (for example, on some *nix systems: service php-fpm restart. Your exact command may vary.)
If it's off in your php.ini, my guess is that it's being overridden somewhere else -- either later in the script ('grep "ini_set" /path/to/project/*.php' will find it). Also, the PHP Manual states that if the script has fatal errors, it doesn't apply if there are fatal errors:
Although display_errors may be set at runtime (with ini_set()), it
won't have any effect if the script has fatal errors. This is because
the desired runtime action does not get executed.

how to display errors on MAMP?

I have MAMP, and I don't know how to display errors on it,
when I have error on my php code it shows only blank pages,
i have searched on Google, and I saw that I have to change it to display_errors = on on all of the folders and versions...
and include this on my page:
error_reporting(E_ALL);
ini_set('display_errors', 'on');
Stop your server.
Go to
Applications/Mamp/bin/php/phpVERSION/conf/php.ini
Set
error_reporting=E_ALL
display_errors=On
Start your server.
If this doesn't help - please post your phpInfo page.
This is how I got mine to display error:
Open MAMP
Click on Server tab
Click on PHP
Under Write, check All errors and warnings and Notices
Under To, check Display and Log
I am using MAMP with php version 7.0.6.
What I did was go to MAMP\conf\phpVERSION and open up the php.ini file there and change the display_errors value there to display_errors = On.
Once changed, restart your MAMP.

Can't disable error reporting in OpenCart (PHP)

I can't seem to disable error reporting in PHP - I have tried everything but "Notice" errors are still displayed.
My php.ini has
display_errors = Off;
error_reporting = 0;
My .htaccess has
php_value error_reporting 0
And my script has
ini_set('display_errors', 'Off');
ini_set('log_errors', 1);
ini_set('error_reporting', 0);
ini_set('display_startup_errors', 'Off');
php_info();
echo $my_undefined_var;
The php_info() output confirms that display_errors and error_reporting are indeed off and 0, and yet I still get a notice,
Notice: Undefined variable: my_undefined_var in /my/site/path/index.php?blahblah...
Note this is an OpenCart website (and my change is in the Admin section). I have tried creating a test php script in the same directory as index.php and it's fine.
Is there anything else that could be overriding the error_reporting(0) ?
I've done a grep of the entire site to find and disable all mentions of the error_reporting and display_errors but to no avail.
There is a setting within the OpenCart dashboard that allows you to turn on (or off) error reporting and logging.
Log into your dashboard
In the menu, go to "System" and select "Settings"
In the list of stores, click "Edit" for your store
Click the "Server" tab.
Scroll down, and there's two settings:
a. Log Errors - set this as desired
b. Display Errors - set this to "No"
As #colmde already pointed OpenCart uses custom error_handler.
You can turn error displaying off without any code edits (especially OpenCart core files) via:
Admin->System->Settings->[edit your configured store]->Server->Display Errors
[EDIT]
You can do the same by running following query against OpenCart database:
update setting set `value`= 1 where `key` = 'config_error_display'
OpenCart uses the set_error_handler() function which causes it to override the error_reporting(0).
Removing this fixed my problem.
you can simply use
ini_set('display_errors', 0);
on system/startup.php
True way in OpenCart.
$this->config->set('config_error_display', 0);
$this->processAction(); // it throws ugly warning
I've tested in the controller of my module.
Just to turn off showing errors before your code.
It affects only current session (perhaps even current page).
It doesn't affect the DB!
for me helped:
//error_reporting(E_ALL);
in file startup.php

Error logging with WAMP server in PHP

I have a WAMP 2.2 server running on a Windows 7 box and cannot get PHP error logging working at all.
The file is always blank even after I explicitly trigger USER_ERROR errors, or cause normal ERROR errors.
I'm including the error relevant sections of the php.ini file - hopefully you can find something:
error_reporting = E_ALL
error_log = "c:/wamp32/logs/php_error.log" ;(UNCOMMENTED BY ME)
log_errors = On
display_errors = On
The line ; log_errors is just a comment for the following block, for the purpose of showing you what the settings are in dev vs production. You uncommented four lines which aren't meant to control anything, and I'm surprised your Apache service doesn't have problems starting up because of it.
What you need to do is look for the line:
log_errors = Off
And change the value to On
That said, once you restart the Apache service, the settings should take effect. However, I was unable to get WampServer to properly log php errors despite these settings. Apache will not start up when I specify the error_log parameter.
For me it turned out to be a permissions error. I ended up giving EVERYONE full control of the error log file and it seemed to fix my issue. Best of luck.
Did you try adding these lines to your php file?
ini_set("display_errors", "1");
ini_set("log_errors", "1");
ini_set("error_log", "/wamp64/logs/php_error.log");

Categories