i have done onw project in php. It works on my windows pc. I use xampp on my windows machine.But when i devlopy same on my linux machine it shows me some blank pages.
Some pages are completely blank.some are half blank.
whats the problem?
Those blank pages could be because there is an error that is not displayed -- will be hard to guess what, though, so here are a couple of pointers :
Did you check if there is anything useful in your Apache's log files (something like /var/log/apache/error.log, or close to that, generally).
You can also enable display_errors and/or configure error_reporting, to get more informations -- or have them displayed on screen, which might be a bit easier, as long as you are developping and your application is not deployed to the production server.
This can be done in the php.ini file, if you can modify it, with something like this :
error_reporting = E_ALL | E_STRICT
display_errors = On
html_errors = On
Or it can also be done directly in your code, at the beginning of it, with something like this :
error_reporting(E_ALL);
ini_set('display_errors', 'On');
To enable error_reporting for all kinf of errors, and display those errors.
You might also want to install Xdebug on your development box, to get nice stacktraces when an error / exception occurs -- just don't install it on a production server !
Of course, on your production machine, you probably don't want to display errors ; so that will have to be configured depending on your environment ;-)
Related
I am trying to get PHP errors to display on the screen using IIS vrs 8.5 and PHP vrs 5.2.17, but I continue to get the IIS 500 error http page, or a blank screen. I have already found numerous SO posts that have supposed fixes, but nothing on them has fixed my problem yet. Here is what I have tried.
Changed errorMode to Detailed. Still getting the 500 error page instead of the php error.
Removed all of the custom errors in the default IIS config file under the "httpErrors" block. Still getting the IIS custom 500 error page.
Added existingResponse="PassThrough" to my httpErrors block in the default IIS config. Doing this causes me to get a blank page instead of the php error, or the IIS 500 error.
I have verified that none of these settings are being overwritten in the site default system.config files.
Currently I am getting a blank page instead of the IIS 500 error on the screen. I have already verified that display_errors is on, and error_reporting is correct. I also know that the php page runs just fine. I am purposely causing this php error by removing a semi-colon on the page. So I already know everything is working fine. PHP Error logging is also working, but I want the errors to display on the page so I dont have to look at the error log every 5 minutes.
What else could be causing this?
IF you set custom error to Detailed in feature settings of error pages for website and server both
AND if in your php.ini file you set the display_errors = on & error_reporting = E_ALL
THEN there is only one possibility for getting [IIS default 500 error page] is that "Your PHP is not working coz of miss configuration."
The required configurations are:
After setting Handler Mappings to your php-cgi.exe file(which is in you php installation dir) as FastCGI, open the php.ini file and edit following lines OR add if not found in file. (if php.ini is not exists in you PHP installation dir then rename from existing php.ini-development OR php.ini-production)
1) extension_dir = "ext\"
;ext folder will be in PHP installation, if not create and don't forget ending \
2) log_errors = On
3) error_log = "C:\inetpub\temp\php-errors.log"
4) cgi.force_redirect = 0
; may be you need to add this line add it anywhere, for instance-before '; File Uploads ;'
5) cgi.fix_pathinfo = 1
6) fastcgi.impersonate = 1
7) fastcgi.logging = 0
Be careful and there should not `;` before any of these lines.
see documentation - installing/configuring PHP
Even after correct configurations PHP may not work because of system corruption. You can check by double click on php-cgi.exe and php-win.exe it should run without proper error (other then warnings OR ext/fileName... is missing messages - these are OK).
Note: after these many other setting are requires to run all things of php (ex. session), but by these SIMPLE PHP WILL WORK or PHP will properly show the error for what's wrong (NOT 500 page).
Make sure you are editing the right php.ini file. To check which file needs to be edited, go to IIS > Handler Mappings and look for PHP. Then check which directory they are located in.
In my case, I had two directories and was editing the wrong php.ini file, which was the reason why I was unable to get the errors to display.
I was having a similar issue getting a 500 error instead of a PHP error. I fixed the issue by going to PHP Manager within IIS
Under PHP Settings click configure error reporting. This will allow you to choose between Development and Production machine. If you choose Production you will get no detailed PHP errors in the browser, you will only get wrritten to a logfile. Development will allow for both errors to be displayed and written to a logfile.
I hope this helps.
If ou are Getting error 500 when active php to show errors, maybe you need to turn off the tracking error
Follow the step by step to fix.
If you don't have downnload the PHP Manager for IIS, you can find it in Web Platform Installer. Then open it.
After that click on manage all settings
Now Just turn off this setting
under server configuration feature view you see fast-cgi settings,
double click it. you see php-cgi.exe. double click it. set standart error mode to IgnoreAndReturn200.
regards
I was struggling with this issue - I have my PHP Handler Mapping set as follows, confirming I'm using PHP 5.3:
Therefore I then went to the corresponding location to find the correct file, here: C:\Program Files (x86)\PHP\v5.3 and edited php.ini
At first it looked like this:
; error_reporting
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
I changed it to this:
error_reporting(E_ALL);
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
I had to restart the Server in IIS to apply the change (choosing the Server from the list at the top on the left hand side, rather than selecting the Site on the left, lower down):
Now I see the error message - e.g.
Parse error: syntax error, unexpected '=' in C:\data\test.php on line 2
Instead of this type of generic error - e.g. on Chrome:
For some reason my Mac is displaying the error message "Undefined index: an-undefined-key" whereas on Windows with WAMP it gracefully ignores the exception.
Example of usage:
if ($some_array['an-undefined-key']) {
// ...
}
Is there a PHP configuration which changes this behaviour?
I realise that I can do the following, but I would rather use the above technique if possible:
if (isset($some_array['an-undefined-key']) && $some_array['an-undefined-key']) {
// ...
}
Yes, you need to adjust the error_reporting and display_errors settings which sounds like they are different between your two different environments.
Here are links
error_reporting
PHP ini_set - look at first example for display_errors
The difference between the PHP on your Mac using the installed repo and your WAMP server is the php.ini, try editing your script and append the following lines to the top:
ini_set('display_errors', '1');
error_reporting(E_ALL);
This should be on your scripts. If this is not the problem, then please comment back and I will change accordingly.
You should not add unnecessary line to your script as you will have to change them when you go live.
Edit you php.ini ( using the wampmanager menus so you get the correct file )
left click wampmanager -> PHP -> php.ini
Look for these parameters and change to these values
error_reporting = E_ALL
This one makes error show on the web page
display_errors = On
error_log = "c:/wamp/logs/php_error.log"
this one will make the errors log into the file specified by error_log even if they dont show on the screen
log_errors = On
WAMP comes with XDEBUG configured so you should now see big orange errors in the web page
Check the bottom of the php.ini file for this line. Numbers for versions may differ on your system
; XDEBUG Extension
zend_extension = "c:/wamp/bin/php/php5.X.Y/zend_ext/php_xdebug-2.2.0-5.3-vc9.dll"
Every time I have an error within my code and try to run it, the page becomes inaccessible. This is clearly very frustrating as it's hard debugging code with no feedback.
Relevant information from cPanel:
Apache version 2.2.22
PHP version 5.3.14
MySQL version 5.1.68-cll
Architecture x86_64
Operating system linux
If more information is required then please ask, I'm sorry I cannot provide any more information but frankly I am stumped.
Thanks.
Enable error reporting to see what error PHP had, if it had one.
There are several places you can look, firstly try checking your Apache error log. In many cases this is located in /var/log/apache2/error.log . Another way to debug a page like this is to enable error logging.
The simplest way of doing this being adding these lines to your php file:
ini_set('display_errors',1);
error_reporting(E_ALL);
In addition to this, you can also clean up the errors formatting by adding:
ini_set('html_errors', 'On');
In addition to this method of enabling error reporting, you may also enable them from you configuration file by adding the following line:
error_reporting = E_ALL
You need to update your php.ini to display errors. There are a couple settings.
Search your php.ini for display_errors and error_reporting. The file is usually commented very well on the options for error reporting, but error_reporting = E_ALL is a typical setting. Sometimes people want to suppress notices and set error_reporting to E_ALL & ~E_NOTICE.
display_errors = On is the config to print the errors to the screen.
After changing your php.ini, Apache usually needs to be restarted. I'm not sure how much control you have over your server, so if you can't restart Apache but you have a php.ini available, your host probably has it configured so you don't need to restart.
I have moved my app to OpenShift and now, for convenience of getting it actually work, I'd like to enable in-page errors and warnings. Currently, I see a blank page.
How can I enable errors?
In PHP, it's in php.ini
error_reporting = E_ALL
display_errors = 1
On the IRC channel #openshift, I was told that this is not currently not configurable
(05:06:58 PM) pmorie: ozizka-ntb: it looks like it's provided by the cart - i don't believe you can substitute your own
and I need to use both
error_reporting(E_ALL);
ini_set('display_errors', 1);
You might want to set APPLICATION_ENV to development.
$ rhc env set APPLICATION_ENV=development
According to https://developers.openshift.com/en/php-getting-started.html,
In development mode, your application will:
Show more detailed errors in browser
Display startup errors
Enable the Xdebug PECL extension
Enable APC stat check
Ignore your composer.lock file (if applicable)
If you can't access php.ini then write this on top of your php page:
<?php
error_reporting(22527);
?>
This displays all errors and warnings in the page.
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");