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);
Related
In my settings.php file (located in /sites/default/), I have:
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 'stdout');
However, they are not showing on the screen.
For example, I had a problem where I was missing $ when referencing a variable and it would've been nice to have this displayed.
This has to be in the settings.php file because I have a test site and a live site and only the test site should display the PHP errors, so putting this in a php.ini file at the server level is not an option)
Go to Error reporting page (/admin/settings/error-reporting) and check that error reporting parameter. Is it set just to log errors or to log and display on screen?
If that doesn't help then run phpinfo() (http://php.net/manual/en/function.phpinfo.php) function and see is error display allowed. If it's not check the location of used php.ini file (again be looking at phpinfo() output), edit it to allow error displaying (restart web server) and error should appear.
I have upgraded PHP from 5.4 to 5.6 on one of our local servers, and now I have a php file, which when I try to open from the browser, it only results in a blank white screen.
The error reporting in php.ini is set to on, and I've also told at the beginning of the file to report all errors, yet the output is still blank. When I checked the error_log, it is empty. If I delete the whole content of the .php file, and replace it with a simple echo, everything works perfectly.
How could I debug this error?
Problem : Your error_reporting function may be off in your php.ini file.
Solution :
Sometimes by default in php.ini the display error function is off or allowed to show limited errors.
DISPLAY ERROR'S IN YOUR PHP FILE :
So to enable displaying errors in your php file,You will need to add one of the following statements at the begining of your php file just right after your <?php starting tag.
Note : By using any one of these statements,your php file will show every possible error.!
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
Reference Links :
http://php.net/manual/en/errorfunc.configuration.php#ini.display-errors
http://php.net/manual/en/errorfunc.configuration.php#ini.display-startup-errors
http://php.net/manual/en/function.error-reporting.php
#Credit Goes To #brslv
I am getting internal server error when calling php script via ajax. I set ini_set("display_errors", 1); error_reporting(E_ALL); but still no details .. what else should I do
inside your php.ini the
display_errors = On
The php.ini file is where base settings for all php on your server, however these can easilybe overridden and alterd any place in the PHP code and affect everything following that change. This happens a in frameworks. A good check is to add the display_errors to you php.ini. If you don't see an error, but one is being logged, insert this at the top of the file causing the error:
ini_set('display_errors', 1);
error_reporting(E_ALL);
If this works then something earlier in your code is disabling error display.
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.
I installed XAMPP 1.7.4 (with PHP 5.3.5), the problem is PHP does not display any error messages. E.g. if I connect to MYSQL with mysql_connect() without parameters, PHP will not complain about the required fields.
Why is this?
How can I configure PHP to display errors?
To turn on errors at the script level, include at the top of your script:
ini_set('display_errors', 1);
error_reporting(~0);
Alternatively, if it is not a production site and simply a development / testing site, you can turn on error reporting in php.ini. Search it for these settings:
error_reporting = E_ALL
;error_reporting = E_ERROR
display_errors = On
;display_errors = Off
May be the display error is off
add in .htaccess file of your application.
php_value display_errors on
OR
use this at the top of your php script
ini_set('display_errors',"1");
To show error message on page over browser for php script use following code in top of your php file.
<?php
ini_set('display_errors', 1);
error_reporting(~0);
?>
and there is another way to check php error code if you are linux ubuntu user execute following command on terminal.
NOTE : -10 is the number of message you want to show.
It possibly did override your settings in the php.ini. Check the php.ini for error handling parameters and make sure they're switched on.
Happened to me a few weeks ago, too
You can use following code in your program
error_reporting(E_ALL);
ini_set('display_errors', '1');