include problem
Moderator: General Moderators
include problem
On my home page I have been exploring the use of the global php footer
so if I use
<?php include ('global_footer.php'); ?>
it works, but if I use my full domain, it does not, thoughts?
so if I use
<?php include ('global_footer.php'); ?>
it works, but if I use my full domain, it does not, thoughts?
Last edited by Vegan on Wed Sep 22, 2010 1:05 pm, edited 1 time in total.
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
-
lang79james
- Forum Newbie
- Posts: 13
- Joined: Fri Oct 23, 2009 10:40 pm
Re: include problem
If that works then why change it. Or do you want to use it on many pages.
Well for me I got one that is in a date folder and it seems to work well for me.
Some time I have to give the file location like
/var/www/data/####.php
But I can only do this because I am hosting it from home.
Well for me I got one that is in a date folder and it seems to work well for me.
Some time I have to give the file location like
/var/www/data/####.php
But I can only do this because I am hosting it from home.
Re: include problem
I wish to use it all over the site. My site has stewn over many levels deep in a directory tree.
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
Re: include problem
I believe that PHP include is intended only for files on the same server that is running the PHP script, so when you put a domain name in there, it isn't a valid path on the server.
Re: include problem
What can I use to get it used generally?
I noticed when I used ../global_footer.php that the PayPal image did not render when it worked fine on the home page.
Sure seems to be clumsy
I noticed when I used ../global_footer.php that the PayPal image did not render when it worked fine on the home page.
Sure seems to be clumsy
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
-
lang79james
- Forum Newbie
- Posts: 13
- Joined: Fri Oct 23, 2009 10:40 pm
Re: include problem
I remember using the include command to open a file from anther server. I think i did for giggles, but like I said I can do that because I am hosting it . Maybe you can create folder on all off your servers that link to one folder. Just a thought, I forget what it is called though. I know In ISS when i was playing with ASP.NET i was able to do that.
Re: include problem
I am using Linux and the standard LAMP stack
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
-
lang79james
- Forum Newbie
- Posts: 13
- Joined: Fri Oct 23, 2009 10:40 pm
Re: include problem
well if you hosting it your self then why not use the file path.
I know for some stupid reason i have to do this with some of my code to get it working right.
for me i got pages in root and some others in sub dir's. and when I use the file path it works like a champ.
Code: Select all
include '/var/www/footer.php';for me i got pages in root and some others in sub dir's. and when I use the file path it works like a champ.
Re: include problem
I don't see anything in the documentation that leads me to believe that include() can be used to include a file that's not on the same physical server, but I'm certainly not an expert in this area. You might look into curl, which is the command that is intended for accessing external URLs.
Edit: Oh wait, you're not talking about remote servers? Then I don't see what your problem is. If you're trying to include a file that's stored on the same server, and particularly if it's working on one page, then you must just have an error in your code, maybe a simple typo. We can't tell unless you show us the code that DOES work and the code that DOESN'T work.
Edit: Oh wait, you're not talking about remote servers? Then I don't see what your problem is. If you're trying to include a file that's stored on the same server, and particularly if it's working on one page, then you must just have an error in your code, maybe a simple typo. We can't tell unless you show us the code that DOES work and the code that DOESN'T work.
Last edited by califdon on Wed Sep 22, 2010 2:29 pm, edited 1 time in total.
Reason: I re-read your question.
Reason: I re-read your question.
-
lang79james
- Forum Newbie
- Posts: 13
- Joined: Fri Oct 23, 2009 10:40 pm
Re: include problem
I got the impression all of his files are on the same computer
example
|root
|-folder 1
|-- folder 1.1
|-- folder 1.2
|--- folder 1.2.1
|--- folder 1.2.2
|-folder 2
|-folder 3
|--folder 3.1
|---folder 3.1.1
|----folder 3.1.1.1
|-----folder 3.1.1.1.1
and so one
example
|root
|-folder 1
|-- folder 1.1
|-- folder 1.2
|--- folder 1.2.1
|--- folder 1.2.2
|-folder 2
|-folder 3
|--folder 3.1
|---folder 3.1.1
|----folder 3.1.1.1
|-----folder 3.1.1.1.1
and so one
Re: include problem
<?php include('global_footer.php'); ?> // works
<?php include('http://wwww.contract-developer.tk/global_footer.php'); ?> // does not work
<?php include('/global_footer.php'); ?> // does not work
<?php include('http://wwww.contract-developer.tk/global_footer.php'); ?> // does not work
<?php include('/global_footer.php'); ?> // does not work
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
-
lang79james
- Forum Newbie
- Posts: 13
- Joined: Fri Oct 23, 2009 10:40 pm
Re: include problem
what aboutVegan wrote:<?php include('global_footer.php'); ?> // works
<?php include('http://wwww.contract-developer.tk/global_footer.php'); ?> // does not work
<?php include('/global_footer.php'); ?> // does not work
Code: Select all
include './global_footer.php'; Re: include problem
That one seems to work, thanks for the suggestion.
The putative footer is located at the root of the site, so all of the documents are relative to that document root.
The putative footer is located at the root of the site, so all of the documents are relative to that document root.
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
Re: include problem
That's what I said. "http://" says that it is looking for a website using http protocol--it would send a request to the DNS system to obtain an IP address, etc. That's not what include() does. It uses normal file system paths to find a file on the same server. The last one should work if the file is located directly in the Document Root of that server. The first one works because it is in the same directory as the script that's calling it. Using "./" works because it means the same thing: "this directory", but it's not required.Vegan wrote:<?php include('global_footer.php'); ?> // works
<?php include('http://wwww.contract-developer.tk/global_footer.php'); ?> // does not work
<?php include('/global_footer.php'); ?> // does not work
Re: include problem
So what can I do, grab the footer from the database?
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP