My very first php - guess what it doesnt work
Posted 09 July 2006 - 10:15 AM
I have just done my very first piece of php - an include menu file. To be honest I was shocked to see it never worked. Your help would be much appreciated here.
This is the code I used in my index file which can be viewed at www.whitbyseaanglers.co.uk
<?php include("menu.php"); ?>
This is the code in a file named menu.php on my server in the same directory.
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<li><a href="index.htm"> Home</a>
<li><a href="aboutus.htm">Club Details</a></li>
<li> Club Stats
<li><a href="05-06individualcatches.htm">Angler Stats</a></li>
<li><a href="pictures.htm">NE Gallery</a></li>
<li><a href="mailto:firstname.lastname@example.org?subject=Fishing Club">Email</a></li>
<li><a href="http://wsaa.proboard...ex.cgi">Message Board</a></li>
<ul style="position: absolute; left: 0px; top: 19px">
<li><a href="sitemap.htm">Site Map</a></li>
<li><a href="sizelimits.htm">Size Limits</a></li>
<li><a href="http://homepage.ntlw.../index">Fishing at Whitby</a></li>
??? ??? ??? ??? ??? ???
Would someone please let me know where I am going wrong. Kind regards - Glenn
Posted 09 July 2006 - 10:29 AM
The menu doesnt appear.
There should be a menu just below the header image.
Have a look at www.whitbyseaanglers.co.uk The menu hasnt been included.
Posted 09 July 2006 - 05:57 PM
Glen, can you be more specific please. I've put together your files and they appear to work, though your menu system still requires a lot of work.
One point though; when you include a file, remove all the extraneous HTML tags. For instance, after your page has been executed on the server, it shouldn't show multiple BODY or HEAD tags.
Please also mention the server/software/setup that you have for future reference i.e. phpMyAdmin or EasyPHP, etc, etc
Posted 09 July 2006 - 06:50 PM
error_reporting(E_ALL);that should issue a notice if your included file isn't being included. If you read the PHP manual you'd see that the big difference between include and require is that include will fail and issue a notice, whereas require will fail and issue a fatal error and this stopping execution of the script. You wouldn't want your page to load without the menu would you? So you should be using require.....and it just seems best practice to use require_once, since you wouldn't want to include that menu more than one time in the script would you?
It's best practice to set error_reporting to E_ALL to catch all notices and such when you're debugging your system. This really comes in handy with the more complex scripts and helps you catch things like undefined variables which could be the reason why a script doesn't run right.
Your menu.php file appears to be just straight html. Why not just rename it with an html extension instead of php? Is there some reason you want this to be parsed by php?
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users