Solved

php.ini setting

Posted on 2014-04-18
6
302 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
  • 3
  • 2
6 Comments
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 250 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 109

Accepted Solution

by:
Ray Paseur earned 250 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 83

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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 83

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 109

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
I want to echo out my field names with its values into a table 10 34
paypal ipn url 5 57
Loop through multiple arrays 13 28
PHP Query return divisible by 3 3 17
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
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.

773 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