Crowbar Posted February 10, 2013 Share Posted February 10, 2013 (edited) Hi, I am following a tutorial on Youtube and I am trying to construct a php menu that will be a single php file that will be inserted as a header on all my pages. I have created the index.php file and a header.inc.php file (for the header script), and when I insert the "include" code to grab the header and display it, it doesn't show. (yes, my file is misspelled --headder instead of header, so that shouldn't be an issue) Here is my indiex.php code: <?include("inc/incfiles/headder.inc.php"); ?> <body> </html> <table class="homepageTable"> <tr> <td width="60%" valign="top"> <h2>Join friendbook today!</h2> <img src="img/social_image.jpg" width="400"> </td> <td width="40%" valign="top"> <h2>Sign Up Below</h2> <form action="#" method="post"> <input type="text" size="25" name="fname" placeholder="First Name"> <input type="text" size="25" name="lname" placeholder="Last Name"> <input type="text" size="25" name="Username" placeholder="User Name"> <input type="text" size="25" name="email" placeholder="Email"> <input type="text" size="25" name="email2" placeholder="Repeat Email"> <input type="text" size="25" name="password" placeholder="Password"> <input type="text" size="25" name="password2" placeholder="Repeat Password"> <input type="submit" name="submit" value="Sign Up!"> </form> </td> </tr> </table> </body> </html> and here is my "header.inc.php" script that I want to display (I am directing the index.php to grab this code and use it for a common header: <head> <link href="css/main.css" rel="stylesheet" type="text/css"> <title>friendsBook - A New social network</title> <head> <body> <div class="headerMenu"> <div id="wrapper"> <div class="logo"> <img src="img/logo.png"> </div> <div class="search_box"> <form method="GET" action="search.php" id="search"> <input name="q" type="text" size="60" placeholder="search ..." /> </form> </div> <div id="menu"> <a href="#">Home</a> <a href="#">About</a> <a href="#">Sign Up</a> <a href="#">Login</a> </div> </div> </div> <br /> <br /> <br /> <br /> Any help would help me from pulling out my hair at this point. Jimmy Edited February 10, 2013 by Zane Quote Link to comment Share on other sites More sharing options...
Crowbar Posted February 10, 2013 Author Share Posted February 10, 2013 If you want to see the tutorial I am following to see if I have missed something, here is the link: https://www.youtube.com/watch?v=o-VYnWXAUdw Quote Link to comment Share on other sites More sharing options...
Drongo_III Posted February 10, 2013 Share Posted February 10, 2013 Here are a few things to try and help you resolve the issue: 1) ensure error reporting is on - error_reporting(E_ALL); . This might give you a clue as to the issue. 2) Your include uses short tags, i.e. <? SOME PHP CODE ?> instead of full tag structure <?php SOME PHP CODE ?>- So try using full tags as depending your individual configuration short tags may not be enabled. <?include("inc/incfiles/headder.inc.php"); ?> Hi, I am following a tutorial on Youtube and I am trying to construct a php menu that will be a single php file that will be inserted as a header on all my pages. I have created the index.php file and a header.inc.php file (for the header script), and when I insert the "include" code to grab the header and display it, it doesn't show. (yes, my file is misspelled --headder instead of header, so that shouldn't be an issue) Here is my indiex.php code: <?include("inc/incfiles/headder.inc.php"); ?> <body> </html> <table class="homepageTable"> <tr> <td width="60%" valign="top"> <h2>Join friendbook today!</h2> <img src="img/social_image.jpg" width="400"> </td> <td width="40%" valign="top"> <h2>Sign Up Below</h2> <form action="#" method="post"> <input type="text" size="25" name="fname" placeholder="First Name"> <input type="text" size="25" name="lname" placeholder="Last Name"> <input type="text" size="25" name="Username" placeholder="User Name"> <input type="text" size="25" name="email" placeholder="Email"> <input type="text" size="25" name="email2" placeholder="Repeat Email"> <input type="text" size="25" name="password" placeholder="Password"> <input type="text" size="25" name="password2" placeholder="Repeat Password"> <input type="submit" name="submit" value="Sign Up!"> </form> </td> </tr> </table> </body> </html> and here is my "header.inc.php" script that I want to display (I am directing the index.php to grab this code and use it for a common header: <head> <link href="css/main.css" rel="stylesheet" type="text/css"> <title>friendsBook - A New social network</title> <head> <body> <div class="headerMenu"> <div id="wrapper"> <div class="logo"> <img src="img/logo.png"> </div> <div class="search_box"> <form method="GET" action="search.php" id="search"> <input name="q" type="text" size="60" placeholder="search ..." /> </form> </div> <div id="menu"> <a href="#">Home</a> <a href="#">About</a> <a href="#">Sign Up</a> <a href="#">Login</a> </div> </div> </div> <br /> <br /> <br /> <br /> Any help would help me from pulling out my hair at this point. Jimmy Quote Link to comment Share on other sites More sharing options...
Crowbar Posted February 10, 2013 Author Share Posted February 10, 2013 I'm a serious newbie here and this is literally my second day at this. I am using the conTEXT editor and don't see an "error" detection option. I'll look once again. Quote Link to comment Share on other sites More sharing options...
Crowbar Posted February 10, 2013 Author Share Posted February 10, 2013 Oh, THANKS! BTW Quote Link to comment Share on other sites More sharing options...
Crowbar Posted February 10, 2013 Author Share Posted February 10, 2013 Hmmm, I changed the include to the longer tag you suggested, but still not correcting. I don't see teh error detector option in conText, so haven't tried that yet. Quote Link to comment Share on other sites More sharing options...
tibberous Posted February 10, 2013 Share Posted February 10, 2013 I'm a serious newbie here and this is literally my second day at this. I am using the conTEXT editor and don't see an "error" detection option. I'll look once again. You don't turn error reporting on in your editor, it's a feature in PHP that you turn on in the php.ini file. The path to you menu starts with this: inc/incfiles/ which means it needs to be in a folder called incfiles in a folder called inc. Quote Link to comment Share on other sites More sharing options...
timothyarden Posted February 10, 2013 Share Posted February 10, 2013 <body> </html> at the start of your html code you open your body before html and when you do the html markup it has a slash in front of it try reversing it to <html> (notice slash is not in front of it) <body> Also as Drongo_III said try the 'long hand' php tags Try including this after the <html> & <body> <?php include("inc/incfiles/headder.inc.php"); ?> Quote Link to comment Share on other sites More sharing options...
Crowbar Posted February 10, 2013 Author Share Posted February 10, 2013 Ah, I see, I'll need to get up to speed regarding the error thing. Thanks. I did create a file named incfiles, which is where the file resides, but it doesn't seem to grab it from there. I've also tried just creating a header.php file in my main directoy folder and not using the inc/incfiles/header.inc.php direct, but that didn't work either. On the tutorial, it shows that I have done everything exactly like them, but I've been trying to figure this out for about three hours now---ugh. Quote Link to comment Share on other sites More sharing options...
doddsey_65 Posted February 10, 2013 Share Posted February 10, 2013 Hmmm, I changed the include to the longer tag you suggested, but still not correcting. I don't see teh error detector option in conText, so haven't tried that yet. At the top of your php file use error_reporting(E_ALL); ini_set('display_errors', 'on'); That will show all errors. Also if you are learning php don't wrap your includes and requires in brackets. These are statements not functions They will still work your way however Quote Link to comment Share on other sites More sharing options...
Crowbar Posted February 10, 2013 Author Share Posted February 10, 2013 Okay, I'm goning to take a quick look at all this---thanks so much. Quote Link to comment Share on other sites More sharing options...
Crowbar Posted February 10, 2013 Author Share Posted February 10, 2013 I have another odd question (for me anyway), when I created the header.php file and saved it in the folder, the tutorial suggested I name it "header.inc.php" (I suspect that was just their choice). I did call it that, but when the file was created it only shows the title of the file is "header.inc" and it does not "show" the php in the title. Is that normal? Quote Link to comment Share on other sites More sharing options...
doddsey_65 Posted February 10, 2013 Share Posted February 10, 2013 If you are using windows then it hides extensions of files by default Quote Link to comment Share on other sites More sharing options...
Crowbar Posted February 10, 2013 Author Share Posted February 10, 2013 Yes, windows. So, when I actually type the title as :header.inc.php" it will read the php as a file type and hide it (not as part of the title)? Thanks Quote Link to comment Share on other sites More sharing options...
Crowbar Posted February 10, 2013 Author Share Posted February 10, 2013 Okay, I tried the error script you guys gave me. As far as I can tell, it detected nothing--I assume it would call out things, right? And I've tried all teh suggestions as far as script changes, longer code call outs and checked the filie locations, but I still don't get the menu showing up in the browser (and not error prompts either), its just not there. Quote Link to comment Share on other sites More sharing options...
Crowbar Posted February 10, 2013 Author Share Posted February 10, 2013 Here is the script that I am working with now, with the minor suggestion changes from you all (THANKS). index.php: <? include("inc/incfiles/header.inc.php"); ?> <table class="homepageTable"> <tr> <td width="60%" valign="top"> <h2>Join friendbook today!</h2> <img src="img/social_image.jpg" width="400"> </td> <td width="40%" valign="top"> <h2>Sign Up Below</h2> <form action="#" method="post"> <input type="text" size="25" name="fname" placeholder="First Name"> <input type="text" size="25" name="lname" placeholder="Last Name"> <input type="text" size="25" name="Username" placeholder="User Name"> <input type="text" size="25" name="email" placeholder="Email"> <input type="text" size="25" name="email2" placeholder="Repeat Email"> <input type="text" size="25" name="password" placeholder="Password"> <input type="text" size="25" name="password2" placeholder="Repeat Password"> <input type="submit" name="submit" value="Sign Up!"> </form> </td> </tr> </table> </body> </html> and the header.php file: <head> <link href="css/main.css" rel="stylesheet" type="text/css"> <title>friendsBook - A New social network</title> <head> <body> <div class="headerMenu"> <div id="wrapper"> <div class="logo"> <img src="img/logo.png"> </div> <div class="search_box"> <form method="GET" action="search.php" id="search"> <input name="q" type="text" size="60" placeholder="search ..." /> </form> </div> <div id="menu"> <a href="#">Home</a> <a href="#">About</a> <a href="#">Sign Up</a> <a href="#">Login</a> </div> </div> </div> <br /> <br /> <br /> Quote Link to comment Share on other sites More sharing options...
Crowbar Posted February 10, 2013 Author Share Posted February 10, 2013 Oh, in the course of things I corrected the spelling of the header file. Quote Link to comment Share on other sites More sharing options...
timothyarden Posted February 10, 2013 Share Posted February 10, 2013 Add <html> to the top of header.php + change the second <head> tag to </head> Quote Link to comment Share on other sites More sharing options...
doddsey_65 Posted February 10, 2013 Share Posted February 10, 2013 Does "inc/incfiles/header.inc.php" defiantly exist? This is relative to the file you are including it from So if your index.php is in ROOT then this file should be in ROOT/inc/incfiles/header.inc.php Also if this is from a tutorial then i suggest you find another, some of the HTML you are using is seriously outdated. Quote Link to comment Share on other sites More sharing options...
Crowbar Posted February 10, 2013 Author Share Posted February 10, 2013 Hmmm, I was wondering about the datng of the tutorial, thanks. Yeah, I definitely have the header,inc,php file in a folder named "inc" with a subfolder named "incfiles", so it should see it there, right? Those folders are in my root folder. Quote Link to comment Share on other sites More sharing options...
doddsey_65 Posted February 10, 2013 Share Posted February 10, 2013 Did you do as suggested and replace your second <head> tag with a </head> tag The head tag needs to be closed Quote Link to comment Share on other sites More sharing options...
Drongo_III Posted February 10, 2013 Share Posted February 10, 2013 Umm out of interest. You are actually running this on a web server right? Not just from your local machine? Quote Link to comment Share on other sites More sharing options...
dmcglone Posted February 10, 2013 Share Posted February 10, 2013 <?include("inc/incfiles/headder.inc.php"); ?> Should this be "header.inc.php" and not "headder.inc.php"? Quote Link to comment Share on other sites More sharing options...
dmcglone Posted February 10, 2013 Share Posted February 10, 2013 Okay, I tried the error script you guys gave me. As far as I can tell, it detected nothing--I assume it would call out things, right? And I've tried all teh suggestions as far as script changes, longer code call outs and checked the filie locations, but I still don't get the menu showing up in the browser (and not error prompts either), its just not there. try puting this at the top of your page: error_reporting(E_ALL | E_STRICT); ini_set('display_errors', '1'); Quote Link to comment 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.