Hi all
I'm after a bit of advice if I may.
I use INCLUDE a lot on my sites for things like site headers and footers and connection stings to SQL databases.
MY include statements look something like
include('/home/content/29/7034929/html/scripts/header.php');
Which is great and works for me...however I am about to move a site to a new host and initial part of the include path is going to change which means I am going to have to run through replacing the path with the new one in many places.
So as to avoid this problem in the future how should I correctly set the path so I need only to change it in minimal locations? In the php.ini file maybe or set the path as some sort of global variable or session variable.
Also am I correct in my understanding that I am talking about the absolute path in this example?
Any help and suggestions greatly appreciated.
Many thanks
Chris
INCLUDE when moving to another host [SOLVED]
Moderator: General Moderators
INCLUDE when moving to another host [SOLVED]
Last edited by christh on Wed Nov 16, 2011 12:04 pm, edited 1 time in total.
Re: INCLUDE when moving to another host
You're currently using absolute paths. Using relative paths will make your life much easier.
Re: INCLUDE when moving to another host
Thanks Celauran
I can't remember why but when I first started teaching myself I couldn't get my includes to work with relatives paths.
Maybe it was my inexperience at the time.
I'll try switching and see.
Thanks
Chris
I can't remember why but when I first started teaching myself I couldn't get my includes to work with relatives paths.
Maybe it was my inexperience at the time.
I'll try switching and see.
Thanks
Chris
Re: INCLUDE when moving to another host
hmmm
If I change it a relative path of /scripts/header.php
I get the following error
Warning: include() [function.include]: Failed opening '../scripts/header.php' for inclusion (include_path='.:/usr/local/php5/lib/php') in /home/content/29/7034929/html/index.html on line 10
I guess this is why I went with an absolute path in the early days and never changed.
Chris
If I change it a relative path of /scripts/header.php
I get the following error
Warning: include() [function.include]: Failed opening '../scripts/header.php' for inclusion (include_path='.:/usr/local/php5/lib/php') in /home/content/29/7034929/html/index.html on line 10
I guess this is why I went with an absolute path in the early days and never changed.
Chris
Re: INCLUDE when moving to another host
Absolute paths start with a /, relative paths don't.
Code: Select all
include 'scripts/header.php';Re: INCLUDE when moving to another host
Brilliant!
Thanks for your help
Chris
Thanks for your help
Chris