View Full Version : PHP problem. Header.php?!
wildside
03-31-2009, 03:13 PM
I just started a website. I have the hosting and domain all up and going. I use php codes. I have my index.php and my header.php
Now I am ready to code my content and navigation pages. For example..castcrew.php
My question is how do I have my header shown and included in my castcrew.php..so my layout and side bar is included.
I put this code on the page, but it doesn't work..
<?php include("header.php"); ?>
It doesn't work. I tried google and everything else. I can't figure this out.
Schmoopy
03-31-2009, 03:16 PM
That code is correct, however you must make sure that "header.php" is in the same directory as the file that has this code, also make sure that header.php has code in it, or it will look like nothing's happened.
If you want more help, post a link to your site and I'll see what's going wrong or paste the code from the files.
CrazyChop
03-31-2009, 04:38 PM
As mentioned, header.php must be in the same directory as the file.
However, if the file is included by another php file, the include path may be different.
Let's say your folder structure is such
a.php
/extra/b.php
/extra/c.php
For example, a.php includes /extras/b.php and in b.php you just have a include("c.php");
When you invoke a.php, c.php cannot be found because c.php is expected to be in the same directory as a.php
If you are absolutely sure the files are in the same directory, try this
include_once(dirname(__FILE__)."/header.php");
If you have doubts about where a file resides in, you can also echo out dirname(__FILE__) to see which directory it is in.
wildside
03-31-2009, 04:48 PM
my website is http://www.wildsideproductions.net
the coding is
http://www.wildsideproductions.net/indexx.php
http://www.wildsideproductions.net/header.php
http://www.wildsideproductions.net/castcrew
CrazyChop
03-31-2009, 04:53 PM
You have an index.php inside castcrew right?
it should be include_once("../header.php");
../ means to go back down one directory.
From the error message, PHP is expecting index.php and header.php to be inside the castcrew directory. It is one directory down, hence ../header.php
wildside
03-31-2009, 05:15 PM
I just took your advice. The code it working, but now, when I click on cast/crew, my cutenews comes up in the content section. I only want my content on my cast/crew page to come up. I don't want cutenews showing, unless someone is on my home.
you can see what i mean here..
cutenews shows, which i want.
http://www.wildsideproductions.net/indexx.php
cutenews shows here too..which i dont want.
http://www.wildsideproductions.net/castcrew/
Lpe04
04-01-2009, 01:38 AM
On the castcrew page you need to remove the code that inserts the cutenews.
Cheers,
wildside
04-01-2009, 02:15 AM
What is the code I need to remove? This is all the coding that is in my castcrew page...
<html>
<body>
<link rel="stylesheet" type="text/css" href="/!/style.css">
<?php include("/home/wildside/public_html/header.php"); ?>
practiceeejfhsdj
Lpe04
04-01-2009, 02:22 AM
Oh, so you put all your code in the header? Well you will have to break it up if you want to remove certain parts from other pages or else header will be the same for every single page and you won't be able to change it.
wildside
04-01-2009, 02:45 AM
How can I break it up?
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.