Solved

php error reporting

Posted on 2014-01-14
4
339 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
ID: 39780010
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
ID: 39780045
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
ID: 39780090
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
ID: 39780541
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mimic google as my ip 11 53
PHP7 and Sql Server Windows 2008 R2 13 85
Php pie charts 3 26
Whether to store ID's or text values for detailed information 3 20
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

919 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

20 Experts available now in Live!

Get 1:1 Help Now