Solved

php.ini setting

Posted on 2014-04-18
6
295 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 82

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 108

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 82

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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 82

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 108

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now