Jump to content

I need help with an "include" script issue


Crowbar
 Share

Recommended Posts

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 by Zane
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

<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"); ?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 />

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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');

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.