Training, Open Source
computer languages


PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
getting php to give the error messages you want

Posted by julian (julian), 13 November 2005
I am using php version 5.0.4 running on windows and configured to run on an apache server ver 2.0.54

I am at the mo learning about cookies, and have written some code to create a cookie,  I have started off putting in a deleberate mistake.........

The code:
<?php
// this is new code j bowler 2005
if (!isset($_COOKIE['visited']))

 {

   echo 'Welcome to my website! Click here for a tour';
 }
 
 setcookie('visited', '1', time() + 3600 * 24 * 365);
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

</body>
</html>

I expected the computer to print out the  echo statement before set cookie is called ... and I expected that to display an error message... saying that HTTP Headers can not be added after content has already been sent....... ?? But on my system it does not complain at all.....??
So how do I get the php to find the error and to display a warning..... I think it should display a warning shouldn't it  

I have set up in php.ini the following lines
error_reporting = E_ALL | E_STRICT

also display_errors = On

Help please I don't understand why php does not complain.. Ta Julian

many thanks





Posted by admin (Graham Ellis), 13 November 2005
It may depend on your output_buffering configuration.  Although the header should come first, if you have configured output buffering on then it won't actually matter as the PHP script will complete before any of the output actually happens.   If this is the case, it does mean that code that works with your particular setup may fail when moved elsewhere, so I recommend against relying on it!

Posted by julian (julian), 13 November 2005
Thanks for your reply.. it may well have something to do with output buffering..... perhaps... but I think It is more fundamental than that may be... It seems thet my php engine does not produce any error messages at all as far as I can see!!!!! I have looked at the php.ini file and I do have the line error_reporting = E_ALL as well as display_errors = On. but still no error messages in the browser window.

It seems at the moment if I run a php program that has things wrong with it---  like anything wrong with it.... I just get a blank white screen in the browser and thats all.
Have you please got any advice that will help me find out why error reporting seems to be nin existant

Could it be that some how the php installation is corrupt or the software that makes php funcrion has got confused I know I am confused a lot

Any help would be very much appreciated Ta Julian

Posted by admin (Graham Ellis), 14 November 2005
You many be logging to file ....

I'm away (and connected in via a mobile phone) until Wednesday ... I'll have a look when I get back.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.


WELL HOUSE CONSULTANTS LTD.: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho