Solved

php error reporting

Posted on 2014-01-14
4
336 Views
Last Modified: 2014-01-14
I am used to seeing syntax errors in php (if any) when I open a page, especially one I just coded which of course can easily have typos.

I am operating (in this case) on a dedicated cloud server; when there are syntax errors, I just get a blank page. Makes debugging terribly difficult.

The server has "Plesk"; I found a way to a adjust php settings; specifically I set error_reporting to E_ALL | E_STRICT & I set display errors to "on" (see attached).

I still get a blank page.

How can I fix this?

Thanks
0
Comment
Question by:Richard Korts
  • 2
4 Comments
 
LVL 34

Accepted Solution

by:
gr8gonzo earned 500 total points
Comment Utility
Create and run a script containing:
<?php
phpinfo();
?>

That should tell you where your php.ini file is located so you can make the proper changes. You seem to have the right settings, so if you've rebooted the web server (necessary for PHP.ini changes) and you're still not seeing the errors, then it probably means you're updating the wrong php.ini file.
0
 

Author Comment

by:Richard Korts
Comment Utility
I don't know how to reboot the web server, that is probably the issue.

Can I do that from "Plesk"?
0
 
LVL 34

Expert Comment

by:gr8gonzo
Comment Utility
Here's the general instructions for it:
http://kb.parallels.com/en/122

I'd also recommend enabling graceful restarts to minimize disruptions from restarts:
http://kb.parallels.com/en/112020
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
You may also want to have an error_log file.  You can use something like this in php.ini:

log_errors = On
log_errors_max_len = 1024
error_log = error_log

Open in new window

You can monitor the directories of the site for the appearance of the error_log with something like this:

<?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

HTH, ~Ray
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Mysqli Query 5 40
how can I dected if URL has variable? 7 21
Creating a slider 12 32
sql sentence 2 10
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

772 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