Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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.

You can Add a comment or ranking to this page

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