PHP - Where is there error reporting?

Why does this produce no error output?

<?php
error_reporting(E_ALL);

ini_set('display_errors', 1);

include("header.php");
include("menu.php");
$info=urldecode($_GET["info"]);
$info=explode("%f ", $info);
$c=$_GET["c"];
$r=$_GET["r"];

$row=explode("%i ",$info[$r]);
 
echo "<div class=\"content\">";

echo "<table><tr><td>";
echo "<img id=\"pic\" src=\"",$row[0],"\" style=height:425px><td style=\"width:3%;\">";
echo "<td>",$row[1];
echo "<tr><td>All images copyright Linda Matthews.";
echo "<td><button onclick=\"prevPicture\"> Next </button>";
          <button onclick=\"history.go(-1);\"> Thumbnails </button>";
          <button onclick=\"nextPicture\"> Next </button>";
echo "</table></div>";

include("footer.php");


echo "<script type="text/javascript">"
echo "    function prevPicture {"
echo "        document.getElementById(\"pic\").src=\"art/zen03.jpg\";";
echo "    }";

echo "   function nextPicture {"
echo "        document.getElementById(\"pic\").src=\"art/zen04.jpg\";";
echo "    }";
echo "</script>";

Open in new window

padmasambhavaAsked:
Who is Participating?
 
GaryConnect With a Mentor Commented:
Should there be an error?

Could be that the php.ini file is set to not display errors, in php.ini look for

display_errors = On

should be set to On
0
 
Loganathan NatarajanLAMP DeveloperCommented:
After setting the above configuration, you need to restart the apache
0
 
Marco GasiFreelancerCommented:
Or you can put this line at the top of the script

ini_set("display_errors", "On");

Open in new window


Since these two statements don't take effect if there is a parse error (before an error be thrown it's necessary parse the entire file and if a parse error is found no code is executed), you could place these two line in one file (let's say 'main.php') and then iclude your actual file in this new one:

main.php
<?php
error_reporting(E_ALL);
ini_set("display_errors", "On");
include("your_file.php");

Open in new window


Then try to execute main.php: the two statements referring to error reporting will be executed, then your file will be included and any error displayed.

Cheers
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
padmasambhavaAuthor Commented:
It produces no output. It doesn't generate any html.
0
 
Marco GasiFreelancerCommented:
Even separating error code from the rest? Well, since I don't see any error in your code, try to look at the includeed files.
0
 
InsoftserviceCommented:
Try

ini_set("display_errors", 1);
ini_set("track_errors", 1);
ini_set("html_errors", 1);
error_reporting(E_ALL);

set_error_handler("var_dump");
0
 
Julian HansenCommented:
Added code tags ...

Sometimes ISP's turn off error reporting and you can't turn it on - so if you have tried the above try adding the following to an .htaccess in your root folder
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
php_flag  log_errors on
## Change the path below to match the path to your website
php_value error_log  /home/path/public_html/domain/PHP_errors.log;

Open in new window


Failing that some ISP's create a an error.log file automatically in the root - check to see if there is one there.

If that does not pan out - try creating your own error handler (Refer http://php.net/manual/en/function.set-error-handler.php for more information)
$old_error_handler = set_error_handler("myErrorHandler");
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
    echo "Error {$errno}, {$errstr} in {$errfile} on line {$errline}";
}

Open in new window

Failing that try the brute force approach
Add output lines as shown below - you should get a trace of how far the application gets before terminating. The last output message should be the line just before the statement generating the error.
"File: " . __FILE__ . ", Line: " . __LINE__ . "<br/>";
include("header.php");
"File: " . __FILE__ . ", Line: " . __LINE__ . "<br/>";
include("menu.php");
"File: " . __FILE__ . ", Line: " . __LINE__ . "<br/>";
$info=urldecode($_GET["info"]);
"File: " . __FILE__ . ", Line: " . __LINE__ . "<br/>";
$info=explode("%f ", $info);
"File: " . __FILE__ . ", Line: " . __LINE__ . "<br/>";
$c=$_GET["c"];
"File: " . __FILE__ . ", Line: " . __LINE__ . "<br/>";
$r=$_GET["r"];
"File: " . __FILE__ . ", Line: " . __LINE__ . "<br/>";

"File: " . __FILE__ . ", Line: " . __LINE__ . "<br/>";
$row=explode("%i ",$info[$r]);

Open in new window

0
 
Ray PaseurCommented:
I use these settings in my php.ini file and I get errors reported and logged correctly.
display_errors = On
log_errors = On
log_errors_max_len = 1024
error_log = error_log

Open in new window

Once you have those settings turned on, this script should give you an expected error.
<?php trigger_error("Hello!", E_USER_ERROR);

Open in new window

0
 
padmasambhavaAuthor Commented:
Where is the default location for php.ini and how do I restart apache?
0
 
Ray PaseurCommented:
php.ini is located in the WWW root directory and may be located in sub-directories if you need to change settings in the sub-directories.  You'll have to figure out how to restart the server on your own.  When in doubt, power-off/power-on will override a multitude of sins :-)
0
 
Loganathan NatarajanLAMP DeveloperCommented:
are you using windows or linux? and do you use any software bundle like xampp or wamp server?
0
 
GaryCommented:
Location of php.ini and how you restart Apache will depend on your setup - windows, linux?

php.ini location
If it's windows then it will be in the PHP folder
If Linux then the etc folder

(definitely not in the www root)
0
 
Ray PaseurCommented:
I use Linux.  The php.ini file that is located in my WWW root applies my local preferred settings, and overrides the global settings.  

There may be other places on the server that have a php.ini file, but to say "definitely not in the www root" may give an incomplete understanding of the cascade of directives.  And our author might not want to mess with the global settings (or might not be able to change the global settings) -- at least not until we have a good understanding of the effect of these settings and the changes that might result from a change (or a mistake) in the parent version of php.ini.
0
 
GaryCommented:
Correct, I was thinking about something else
0
 
padmasambhavaAuthor Commented:
I'm on a linux box. So I will try changing php.ini to make showing errors the default.
0
 
padmasambhavaAuthor Commented:
php.ini seems to have no carriage returns. Is it safe to search for the string and change it in place or is there a process that I need to go through? No hurry I have to get access to change it anyway.
0
 
padmasambhavaAuthor Commented:
Thanks Gary and all.
0
 
Ray PaseurCommented:
For anyone coming upon this question in the future, please learn about this native PHP function:
http://php.net/manual/en/function.phpinfo.php
0
All Courses

From novice to tech pro — start learning today.