sudsy1970 Posted April 8, 2010 Share Posted April 8, 2010 hi all, newbie here having difficulting using the include fuction. i am trying to set up a template for a webpage but for some reason the menu does not display. Any ideas please? have looked at w3 and followed the instructions on there but no luck. code posted below. thank you here is the menu <? <TABLE cellpadding="10"> <tr> <td><img src="Images/Banner.JPG" alt="banner"> </td> <td><li> <a href="customer_login.php" rel="nofollow">Log in</a></li> <li><a href="customer_create.php" rel="nofollow">Register</a></li> <li><a href="password_get.php" rel="nofollow">Forgotten password?</a></li></td> </tr> <table> <table cellpadding="20"> <tr> <td><a href="homepage.php" title="Home" >Home</a> </td> <td><a href="register.php" title="Register">Register </a> </td> <td><a href="main.php"title="main" >Members</a> </td> <td><a href="disclaimer.php"title="contact">Fixtures</a> </td> <td> <a href="reports.php"title="Reports">Match Reports</a> </td> <td> <a href="mailto:[email protected]">Contact Us</a> </td> <td> <a href="logout.php"title="logout" >League Table</a></td> </tr> </TABLE> ?> and the page calling it <?php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <LINK rel="stylesheet" href="CSS/home.css" type="text/css"> <title>Home</title> </head> <body> <? include ('menu.php'); ?> </body> </html> ?> Quote Link to comment https://forums.phpfreaks.com/topic/197992-inserting-a-menu/ Share on other sites More sharing options...
tomtimms Posted April 8, 2010 Share Posted April 8, 2010 Perhaps the path to your menu.php is wrong? Have you tried using <?php include($_SERVER["DOCUMENT_ROOT"]."/menu.php"); ?> or perhaps using the full path to your file? http://www.yoursite.com/menu.php Quote Link to comment https://forums.phpfreaks.com/topic/197992-inserting-a-menu/#findComment-1038935 Share on other sites More sharing options...
sudsy1970 Posted April 8, 2010 Author Share Posted April 8, 2010 tried adding both your code and the full address of ther file both to no avail all i get is a <? displayed on the webpage. it seemed so simple too Quote Link to comment https://forums.phpfreaks.com/topic/197992-inserting-a-menu/#findComment-1038937 Share on other sites More sharing options...
teamatomic Posted April 8, 2010 Share Posted April 8, 2010 Your menu.php file contains only html. dump the php tags. HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/197992-inserting-a-menu/#findComment-1039040 Share on other sites More sharing options...
sudsy1970 Posted April 8, 2010 Author Share Posted April 8, 2010 ok does this mean that the file will now be called menu.html and then i can call in menu.html in the include statement ? Quote Link to comment https://forums.phpfreaks.com/topic/197992-inserting-a-menu/#findComment-1039048 Share on other sites More sharing options...
DavidAM Posted April 8, 2010 Share Posted April 8, 2010 You can call the file anything you want as long as you use the same name (and extension) in the include. Personally, I would leave it as .php, then if I later decide to put some php code in the file, I don't have to change anything. Besides, you should add comments to the file to remind you of what is there, etc. and using php comments is cleaner since they don't get sent to the browser: <?php /* menu.php - This file outputs the menu ... */?> By the way use full php tags (as in the example above) rather than short tags (like in your example). If you later move to a server that does not support short tags, you will not have to edit every single file in your system to fix the tags. Quote Link to comment https://forums.phpfreaks.com/topic/197992-inserting-a-menu/#findComment-1039070 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.