Include Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ThinkGeekness
Forum Newbie
Posts: 16
Joined: Sat May 17, 2003 8:00 pm

Include Question

Post by ThinkGeekness »

I am trying to use the Include code and it works if I have:

Code: Select all

<?php include("header.php") ?>
and header.php in the same directory

It doesnt work if I have:

Code: Select all

<?php include("./header.php") ?>


Or:

Code: Select all

<?php include("http://www.mysite.com/header.php") ?>


I get one of the following error messages:
Warning: Failed opening './header.php' for inclusion (include_path='.:/usr/local/lib/php') in /usr/local/apache_1.3.27/htdocs/mysite/subpage/index.php on line 10
or:
Warning: Failed opening 'http://www.mysite.com/header.php' for inclusion (include_path='.:/usr/local/lib/php') in /usr/local/apache_1.3.27/htdocs/mysite/subpage/index.php on line 10
What I basically want to do is to have it point to header.php in the root directory. What am I doing wrong?

Thanks
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

If the php file you're making is in the same directory as "header.php", then you only need to do: include("header.php");

If it isn't, then you should find the full directory to your header.php (example: /home/your_site/htdocs/) and include it like: include("/home/your_site/htdocs/header.php");
Image Image
ThinkGeekness
Forum Newbie
Posts: 16
Joined: Sat May 17, 2003 8:00 pm

Post by ThinkGeekness »

Thanks, I was trying to put the web link instead what the server sees it as.. Thanks again.
Post Reply