Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

php.ini setting

Posted on 2014-04-18
6
Medium Priority
?
322 Views
Last Modified: 2014-04-28
What is the php.ini setting that allows for visibility of syntax errors when compiling?

I am using GoDaddy & on the SPECIFIC account I have (for a customer), the GoDaddy rep doesn't even know what I'm taking about.

I know, I know, a number of you have told me to get off GoDaddy. I don;t always have that choice.

Thanks
0
Comment
Question by:Richard Korts
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 1000 total points
ID: 40009661
I think this is what you want.  http://us1.php.net/manual/en/function.error-reporting.php
// Report all PHP errors (see changelog)
error_reporting(E_ALL);

Open in new window

GoDaddy reps are not coders, you shouldn't expect them to know or answer these kinds of questions.  They are probably told not to anyway.
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 1000 total points
ID: 40009699
Here is what I use:

<?php
ini_set('dosplay_errors', TRUE);
ini_set('log_errors', TRUE);
error_reporting(E_ALL);

Open in new window

But with that said I have still found GoDaddy installations where I could not get the errors displayed and could only get them logged.  The following script can be placed in the WWW root.  It will find and display the error logs.  Not as great as having real-time information, but at least if you get the screen of death you can get a clue from the logs.

<?php // find_error_log.php
error_reporting(E_ALL);
ob_start();

// PUT THIS SCRIPT IN THE WEB ROOT DIRECTORY
$path = realpath(getcwd());
$plen = strlen($path);

// THE ERROR LOG FILE NAME
$signal = strrev('error_log');


// IF THERE IS A POST-METHOD REQUEST TO DELETE THE ERROR LOG
if (!empty($_POST['log']))
{
    // MAKE SURE WE ONLY UNLINK THE ERROR LOG FILE
    $test = strrev($_POST['log']);
    if (strpos($test, $signal) === 0)
    {
        unlink($path . $_POST['log']);
        echo '<h3>' . $_POST['log'] . ' Discarded</h3>';
    }
}


// SEE http://php.net/manual/en/class.recursivedirectoryiterator.php#85805
$objs = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
foreach($objs as $name => $obj)
{
    // PROCESS THE ERROR LOG ONLY
    $test = strrev($name);
    if (strpos($test, $signal) === 0)
    {
        $name = substr($name, $plen);
        $form = <<<EOD
<form method="post" style="margin:0; padding:0; display:inline;!important">
<b>$name</b>
<input type="submit" value="Discard?" />
<input type="hidden" name="log" value="$name" />
</form>
EOD;
        echo $form;

        // SHOW THE CONTENTS OF THE ERROR LOG
        echo '<pre>';
        print_r(file_get_contents($path . $name));
        echo "</pre>";
    }
}

$out = ob_get_contents();
if (empty($out)) echo '<h3>Good News! No error_log found.</h3>';

Open in new window

You may have to define the error_log file in php.ini with something like this.

log_errors = On
log_errors_max_len = 1024
error_log = error_log
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40009729
Note that on Godaddy Linux hosting, you can put a partial 'php.ini' file in the web root but that does not work on their Windows hosting.  On the Windows hosting, it kills the server 'php.ini' file.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Richard Korts
ID: 40009782
There isn't any way to put parameters into php.ini so that EVERY php program reports syntax errors rather than a blank screen?

This seems to be the default at all the other hosts I use and even most of my other GoDaddy accounts.

Thanks
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40009849
On most of the accounts I use, there is no access to 'php.ini' so I have to use the inline versions that Ray and I have shown you.  If you were the hosting company, I think you would find that many, maybe even most, people do not want the errors to show.  So the default is going to be to not show anything that isn't a fatal error.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 40010357
Most professional web developers will suppress the display of errors, if only to avoid showing something that looks unprofessional when a "Sorry,..." message could be displayed instead.  The error logs will contain the diagnostic information.  And as you can see from your experience with GoDaddy, the error logs are where you have to go for dependable access to the diagnostics.
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question