?
Solved

php.ini setting

Posted on 2014-04-18
6
Medium Priority
?
316 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
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 

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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

764 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