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
Related
I cannot view PHP error on Apache of my mac because every time when I changed from php.ini file to display_error On. But when i restart and open the php.info file, it still says display_error Off. Searched for all php.ini file and changed all off to on but still same result. Help please
Use error_reporting(); at the begining of your PHP main file. It will ignore php.ini and obey the error level you set there.
Also, check that your php.ini is not beign use / locked before you make changes on it?
I've got a dev environment and a live environment running on the same host, using nginx with fastcgi. In php.ini, display_errors is set to off, so that the errors aren't displayed on the production site.
Now, on the dev environment, I need to be able to see those errors. So I'd do ini_set('display_errors', 'On');, however, if it's a parse error, that won't be executed and the error won't be shown.
So my question is, is there any way I can safely set display_errors to on in my php.ini file, and then maybe use the virtual host file in nginx to make sure that the errors aren't shown on the production site?
If you are using fastcgi you could configure it to run php with different php.ini files. I'm not familiar with nginx and fastcgi config, so can't provide you any hint on that. See php manual to learn how PHP could be run.
I think you might want to run it like php -d display_errors=On for dev environment
I believe you can set the error reporting level directly in your script using error_report. I don't have any of my code on hand to check for certain, but I know you can change it without touching php.ini.
I have a server setup where a test script with just phpinfo() works fine.
When I try to run my application on it, it shows up as a blank screen.
I am calling index.php from the browser. The first few lines are as:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
require_once('codelibrary...
Yet, the screen continues to be blank.
Edit 1
Here's the structure of the files:
/.htaccess
/index.php
/codelibrary/inc/user-top.php
/codelibrary/inc/variables.php
/codelibrary/inc/config.php
index.php
<?php
require_once('codelibrary/inc/user-top.php');
...
/codelibrary/inc/user-top.php
<?php
require_once("./codelibrary/inc/variables.php");
...
/codelibrary/inc/variables.php
<?php
include_once('config.php');
...
I thought the referencing here might be a problem, so I changed it to:
require_once("./codelibrary/inc/config.php");
as well, but no luck.
Edit 2
Ah ha! Thanks Col and TopQ for pointing out that I should look at the log file, it says:
[10-Sep-2010 17:06:02] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/suhosin.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20090626/suhosin.so: cannot open shared object file: No such file or directory in Unknown on line 0
Try setting display_errors from a .htaccess file
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
Use "view source" in your browser to see if anything is being written by your script that the browser might not be rendering visibly.
EDIT
If you're getting an http 500 response, then you can always do a php lint check on your script from the command line:
php -l <filename.php>
An extremely useful and oft-forgotten check on the syntax of your code.
Check the PHP error log. Usually syntax error or missing dependencies.
The problem is possibly the following: The error occurrs before your script runs (i.e. while parsing. Probably some syntax error). Since your script does not run, the error-level cannot be changed dynamically. You need to set error_reporting in your php.ini, or try fire's suggestion, which should produce equivalent results.
As noted in the other answers here if there is an error present in your script it will fail to set the error levels dynamically.
You can add the proper directives to either the .htaccess file in the current directory, the webserver config or the php.ini file (http://php.net/manual/en/errorfunc.configuration.php). You need to prefix those with the php_flag directive a la php_flag display_errors on.
If you can't add the commands to the .htaccess files it is most probable that your server config does not allow for overrides for those properties. Consult with the server maintainer for either changing these values, allowing you to override these directives on a per-folder basis and having access to error logs for your virtual hosts.
Considering that this is a script that will be executed by a user outside of your group (the browser/webserver) i would think that the file should be set with permissions 755 as this allows the you to make changes and noone else yet ensures that the browser can execute the script (755 -> -rwxr-xr-x)
I am running the latest version of MAMP on Snow Leopard.
My php.ini file has been configured to display errors. display_errors = on. The phpinfo(); page displays the status of error reporting, it is on. I have restarted my web server several times.
I've searched through Google, and I cannot find any similar problem. Everyone just says to do exactly what I have done, but it is not working. The pages will just remain blank, (with no reporting), if I intentionally place errors.
Any thoughts as to what the problem may be?
For any future posters who run into this issue...
I was having the same issue and found that I was making changes to the wrong php.ini files. Run phpinfo and find the path to the active php.ini file to make sure you're editing the correct one.
On my installation of mamp there were multiple instances of the /conf directory with php.ini files. The php.ini files I needed were located in the /bin/php/php[version#]/conf directory and not the MAMP/conf directory.
Exact path to the php.ini file I needed to edit:
Applications/MAMP/bin/php/php5.4.10/conf/php.ini
Change display_errors = Off to display_errors = On
In addition to the display_errors directive, which has to be set to On, you might have to configure error_reporting.
For instance, you can use this in your php.ini file :
error_reporting = E_ALL
Another should, useful to test, might be to place this kind of portion of PHP code at the beginning of your script :
error_reporting(E_ALL);
ini_set('display_errors', 'On');
This is useful when you don't have access to php.ini and/or just want to test quickly, without having to restart the webserver.
As a sidenote, when it comes to displaying errors, the Xdebug extension is really great : when it's installed/enabled/configured, instead of just having an error message, you'll get the full stack-trace, which is much more useful ;-)
I recently experienced the same problem - in my case I had downloaded a client's Wordpress site from their live server that turned out to have been tampered with by malicious script insertion that was overriding the error reporting in order to escape detection.
A little late to help the OP(!), but perhaps of use to future searchers.
There might have a .htaccess file in a directory that overrides the display_errors setting set in php.ini. From your post I assume you didn't explicitly add this but a few frameworks do this by default so might be added that way. Look for a line like this in your .htaccess file:
php_value display_errors 0
and change the value to 1.
If you have several php sdks with several versions, first make it sure you are editing correct php.ini file. If you were right add this two lines at the beginning of the code.
error_reporting(E_ALL);
ini_set('display_errors', 'On'); // or ini_set('display_errors', 1);
Here's a twist to the same answer. I had the same issues, just copied and pasted the ini path from the php info page and still same problems...
turns out I made a syntax mistake when I edited my 'error_reporting' block in the php.ini.
I had E_NOTICE rather than ~E_NOTICE.
:(
So mistakes can happen in the php.ini if you were editing it and totally forgot you edited something.
I've narrowed my problem down somewhat.
When I run "error_log('hey');" from the command line it dumps to STDOUT. But if I run the same code from my web interface (Apache) it puts the error in the error log.
I've checked both ini files, the one Apache is using, and the one in /private/etc (I'm on a Mac running MAMP). Both error_log variables point to the exact same place.
And when I run
echo ini_get('error_log');
The value is the same on the command line as it is in the browser.
What ini setting is misconfigured here? This is quite annoying, as more than just error logging is broken. It's affecting my include paths as well :/
What are you trying to accomplish? Within apache, stderr goes into the error_log... the error_log() function documentation states that by default it logs to the server's error log. If you want to log to a different destination, use the message_type and destination parameters.
You probably need to edit the following config file:
/Applications/MAMP/conf/php5/php.ini
MAMP uses it's own Apache server, which by default runs on port 8080. You probably want to turn off the Apache server in the System Preferences -> Sharing.
Also, try running a PHP file containing:
<?php phpinfo(); ?>
This will tell you which php.ini is actually being read by Apache.
Will
A reason for error_log displaying in the console, and not in the log file might be because of a problem with permissions -- I don't really know MacOS, but as it's UNIX-based, I'm guessing that :
The log file used by Apache belongs to a specific user
When running the script from the console, you are not that user, and you don't have write-access to the log file
If it can't log to the log file, I suppose that error_log is writting to the standard output for error (stderr), which is generally the console.
This comment on the manual's page seems to indicate this might be the cause of your problems (quoting) :
it seems that PHP logs to stderr if it
can't write to the log file. Command
line PHP falls back to stderr because
the log file is (usually) only
writable by the webserver.
Also, make sure the log_errors and display_errors are properly configured in the php.ini file used in CLI :
log_errors boolean
Tells whether script error messages
should be logged to the server's error
log or error_log. This option is thus
server-specific.
And :
display_errors string
This determines whether errors should
be printed to the screen as part of
the output or if they should be hidden
from the user.
Value "stderr" sends the errors to
stderr instead of stdout.
The relevant ini setting here is display_errors.
From the command line a value of On will dump the errors to STDOUT; stderr will divert them to STDERR and Off will suppress them. For Apache only On and Off make any sense.
The odds are that the ini file for Apache has display_errors = Off whilst the one in /private/etc has display_errors = On.
The error_log directive tells PHP where to log errors to, but it also requires log_errors to be set to On, otherwise it has no effect. (Again, chances are the ini file in /private/etc has log_errors = Off.)