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.
Related
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);
This is my PHP script -
<?php
error_reporting(E_ALL);
echo('catch this -> ' ;. $thisdoesnotexist);
?>
Which obviously should show something if it were to be executed.
All I see is an empty page. Why is error_reporting(E_ALL) not working?
<?php
ini_set("display_errors", "1");
error_reporting(E_ALL);
echo('catch this -> ' ;. $thisdoesnotexist);
?>
Does not help either. All I get is an empty page.
I've been to php.ini and set display_errors = On and display_startup_errors = On. Nothing happens.
Your file has a syntax error, so your file was not interpreted, so settings were not changed and you have a blank page.
You can separate your file in two:
File index.php
<?php
ini_set("display_errors", "1");
error_reporting(E_ALL);
include 'error.php';
File error.php
<?
echo('catch this -> ' ;. $thisdoesnotexist);
That error is a parse error. The parser is throwing it while going through the code, trying to understand it. No code is being executed yet in the parsing stage. Because of that it hasn't yet executed the error_reporting line, therefore the error reporting settings aren't changed yet.
You cannot change error reporting settings (or really, do anything) in a file with syntax errors.
In your php.ini file check for display_errors. I think it is off.
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
In your php.ini file check for display_errors. If it is off, then make it on as below:
display_errors = On
It should display warnings/notices/errors.
Please read error_reporting int.
You can try to put this in your php.ini:
ini_set("display_errors", "1");
error_reporting(E_ALL);
In php.ini file also you can set error_reporting();.
Turn on display errors in your ini file:
display_errors string
Just do the following:
Check phpinfo();. Check if display_errors is on or off
If it is On, just add error_reporting(E_ALL); in your primary index file.
If it is Off, just add it in your primary index file
ini_set("display_errors", "1"); // This is the instant setup for individual applications
error_reporting(E_ALL);
then check phpinfo();. Check display_errors. Now it is on, which is only for this application
then create any code error for testing and reload the page
Hurray! Now you can see the errors in your console. If the errors are not displaying in your console and the page loading failed with a red alert in network, don't worry.
Check if you have enabled modsecurity and it has any rule checking is written in SecRule for PHP. Remove that secrule or disable the modsecurity for your development period.
I recently changed to a MacBook and now use the MAMP-stack for development locally.
In my earlier development environment I always could see informative error-reports when I tried to access a PHP file through a web-browser and an error occurred. With the default installation of MAMP it seems that this feature is disabled, whenever I hit an error I can't see the cause of it, I can't even see a single line informing me that an error occurred.
Not until I start to debug the code in a debugger I can see where the error occurred.
Any idea how error reporting can be turned on?
I tried:
error_reporting(E_ALL);
No effect at all though.
reporting level to E_ALL and display errors on Include the following code at the top of every php file on in an include or require such as your config.php
error_reporting(E_ALL);
ini_set('display_errors', 'on');
Try ini_set('display_errors', 'on');
You'll also want to check a phpinfo(), to see if the ini_sets are doing anything.
Or change "display_errors = Off" to "display_errors = On" in /Applications/MAMP/bin/php/php5.4.4/conf/php.ini
Navigate to MAMP settings (eg localhost:8889/MAMP)
Click PHP Tab
Find Log errors: setting
Tick to screen
Click Save
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');
Im lost here, closed few files and clicked yes on save all and now page wont load and error_reporting(1); its in all documents... No erors given
If your error isn't a syntax error, you can manually debug by placing die('test'); in various areas of your code to see if that portion executes.
You also need to turn on the display of errors, so at the top of your file add:
error_reporting(E_ALL);
ini_set("display_errors", 1);
Turn on error_reporting and display_errors in your php.ini file. If you have a syntax errror in the script, most likely the script's being killed long before execution could ever reach in the in-script ini_set/error_reporting overrides.
You might want to check the server's error log, as fatal errors generally get sent there if error reporting/display is turned off.