Show PHP errors on Apache server with shared webhost

I'm building a PHP application on a shared webhost and have tried various methods to show PHP errors.  Here's what hasn't worked.

Code at the top of the PHP file:

error_reporting(E_ALL);
ini_set('display_errors', '1');

.htaccess file in root:

# display php errors
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on

Anyone have other ideas?

Thanks in advance for any help.

Steve
LVL 2
stkoontzAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Who is the web host?  You're doing the right things.
0
Ray PaseurCommented:
You may be able to get the errors logged, too.  Try these in your php.ini

log_errors = On
log_errors_max_len = 1024
error_log = error_log
0
stkoontzAuthor Commented:
My webhost is Bluehost.
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

stkoontzAuthor Commented:
I can't get to the php.ini file since it's a shared server.
0
stkoontzAuthor Commented:
Hi Ray,

The errors are being logged in a file.  It's just a lot easier to have them on the screen when I'm debugging.

Thanks for jumping in to try to help.

Steve
0
Ray PaseurCommented:
Yeah, I agree.  On most hosting services, you can still use php.ini by putting it into your web root.  It should not have any effect on the others who are sharing your server.  Maybe ask the tech support folks at Bluehost about this.  It's a common issue and I'll bet they've dealt with the question before!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
stkoontzAuthor Commented:
I checked the root folder of my sites and found a php.ini file, downloaded it, and can change 'disply_errors' to 'on'.  But that would turn errors on for all of my websites.  I'm trying placing the php.ini file in the folder where the PHP application is located.  (domain.com/folder)

Do you think that will only turn on errors only for code placed in the folder?

Thanks,

Steve
0
Ray PaseurCommented:
Yes, I think so.  I've used different ini files in different directories beneath the WWW root.  You would probably want to set up a quick "parse error" test to run right away on each of your sites (or at least on a few to get proof of concept).
0
stkoontzAuthor Commented:
I created a test file with the following code and uploaded it to the folder with the PHP.ini file in it.  (www.buildmomentum.org/register/test.php)

<?php
This is an error
?>

When I access the page through Firefox, I get a white page.  

The only line of code I changed in the PHP.ini file was...

display_errors = On

Is there more I should change in the .ini file or is my 'error' not enough to trigger an error message.

Thanks!

Steve
0
Ray PaseurCommented:
That is definitely enough to cause a PHP parse error.  

You might also want to try setting these:

error_reporting = 30719
expose_php = on
0
stkoontzAuthor Commented:
To test a hunch, I uploaded a basic php.ini file containing...

display_errors = On
error_reporting = 30719
expose_php = on

...to the root of my hosting plan and the error display worked.  When I reverted back to the original php.ini in the root, the errors didn't display.  When I upload the same php.ini file to the root of the website I'm working on or the folder I'm working in, the errors don't display.

That tells me it's not the php.ini file.  I'll contact Bluehost and see if there's a way to show errors without exposing every website.

Thanks!

Steve
0
Ray PaseurCommented:
Steve: I think that's exactly what I would do, too.  Best of luck with it, ~Ray
0
stkoontzAuthor Commented:
I contacted Bluehost and they sent me instructions to change a setting in cpanel to use site-specific php.ini files.  (Under PHP Configuration, I had to change "PHP 5.2 (Single php.ini)" to "PHP 5.2."

Thanks, Ray, that worked great!
0
Ray PaseurCommented:
Bingo! Glad you got a good result. Thanks for the points and thanks for using EE, ~Ray
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.