1

Possible Duplicate:
How to get useful error messages in PHP?

I am working on the PHP of a site and every time I put any PHP into the code, the whole page is white and refuses to compile.

Now I did the most basic thing I could imagine,on this page: http://www.trulyscience.com/test/PDO.php

<?php
phpinfo();
?>

I am thinking that it has to be a server side problem, (never ran php on this domain before) but my host just told me that I must have a code error.

So my question, is there any way to see whats going on? (phpinfo is not an option sadly)

Community
  • 1
  • 1
Coolcrab
  • 2,655
  • 9
  • 39
  • 59
  • 2
    [`error_reporting(E_ALL)`](http://php.net/manual/en/function.error-reporting.php)? – esqew Aug 24 '12 at 22:59
  • Check the Apache error log. What does it report? – Jocelyn Aug 24 '12 at 22:59
  • If you cannot access any log files, try to add `ini_set('display_errors', true);` right after the first PHP opening tag to (hopefully) get an output. – Niko Aug 24 '12 at 22:59
  • Eighter you don't have PHP or you have a `htaccess` that blocks everything, check `http://www.trulyscience.com/test/` – Mihai Iorga Aug 24 '12 at 22:59
  • Made it `` Still nothing – Coolcrab Aug 24 '12 at 23:01
  • If you do this: ` Hello world!`, does `Hello world!` show up? – Nathaniel Ford Aug 24 '12 at 23:07
  • Yup: http://www.trulyscience.com/test/PDO.php Does this mean that my PHP is turned off/broken? – Coolcrab Aug 24 '12 at 23:08
  • It does appear to be broken somehow, your server is reporting that PDO.php is powered by PHP 5.2.17. – EPB Aug 24 '12 at 23:14
  • It's included in the HTTP response headers. (X-Powered-By: PHP/5.2.17) So phpinfo(); doesn't work. Does `echo "Hi there";` output anything? – EPB Aug 24 '12 at 23:18
  • A re-install of PHP may be in order. – esqew Aug 24 '12 at 23:18
  • It does echo when I do ` echo'hi'; ?>`, and I can't reinstall, the server is maintained by the host (And they are stubborn and keep telling me that everything is fine and that I make PHP errors..) So it would be cool if I could know what was broken so I could tell them or prove it somehow. – Coolcrab Aug 24 '12 at 23:22
  • Hmm... I wonder they've disabled `phpinfo` and the error reporting that would tell you that it is. Though in your comment above it should have been The E_ALL is needed to set the error_reporting. – EPB Aug 24 '12 at 23:27
  • Oh wow, got a response :O `Warning: phpinfo() has been disabled for security reasons in /home/parascie/public_html/Trulyscience.com/test/PDO.php on line 1` – Coolcrab Aug 24 '12 at 23:30
  • That's why was giving you a blank page, they've disabled it and the error reporting. Their PHP is working fine it seems. They just have a very paranoid setup. – EPB Aug 24 '12 at 23:31
  • I got the same prob with a page with actual code on it, so I ask em for turning on errors and phpinfo()? (Anything else I should ask to get turned on?) – Coolcrab Aug 24 '12 at 23:35

1 Answers1

2

So it's not buried in a comment for when people stumble upon this question:

That's why was giving you a blank page, the host has disabled it and the error reporting. Their PHP is working fine it seems. They just have a very paranoid setup.

PHP has the ability to not only turn off error reporting, but also the ability to suppress specific functions from operating. A good absolutely minimal code to test with <?php echo 'Hi'; ?>

You can use ini_set('display_errors', true); error_reporting(E_ALL);. Of course, with this, some pages with compilation errors might give you a blank page. You can ask your host to turn on error reporting or have them point you to a page explaining how you can turn it on, say via .htaccess since you're on Apache. If you really need phpinfo you can ask the same of that.

EPB
  • 3,939
  • 1
  • 24
  • 26
  • I'll ask them to turn on errors, thanks a lot! – Coolcrab Aug 24 '12 at 23:46
  • No problem, I write PHP and manage multiple servers for a living. And for the benefit of anyone who lands here from a google search in the future, there's more information here: http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php – EPB Aug 24 '12 at 23:49