Include troubles...

This is a discussion on Include troubles... within the PHP General forums, part of the PHP Programming Forums category; Im having trouble including files from a particular webhost server. The webhost won't let me change the php.ini ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-08-2004
Nick
 
Posts: n/a
Default Include troubles...

Im having trouble including files from a particular webhost server.
The webhost won't let me change the php.ini file to set the
include_path, so ive been trying to work around it with no luck. So
far ive tried


1. include($_SERVER['DOCUMENT_ROOT'] . "/_includes/menu.php")

Unable to access /var/www/html/_includes/menu.php in
/home/virtual/site136/fst/var/www/html/events/index.php on line 17"

"Warning: main(/var/www/html/_includes/menu.php): failed to open
stream: No such file or directory in
/home/virtual/site136/fst/var/www/html/events/index.php on line 17"

"Fatal error: main(): Failed opening required
'/var/www/html/_includes/menu.php'
(include_path='.:/php/includes:/usr/share/php') in
/home/virtual/site136/fst/var/www/html/events/index.php on line 17"



2. include("/home/virtual/site136/fst" . $_SERVER['DOCUMENT_ROOT'] .
"/_includes/menu.php")

"Warning: main(): Unable to access
/home/virtual/site136/fst/var/www/html/_includes/menu.php in
/home/virtual/site136/fst/var/www/html/events/index.php on line 17"

"Warning: main(/home/virtual/site136/fst/var/www/html/_includes/menu.php):
failed to open stream: No such file or directory in
/home/virtual/site136/fst/var/www/html/events/index.php on line 17"

"Fatal error: main(): Failed opening required
'/home/virtual/site136/fst/var/www/html/_includes/menu.php'
(include_path='.:/php/includes:/usr/share/php') in
/home/virtual/site136/fst/var/www/html/events/index.php on line 17"


Im not having this problem on any other evironments. I cant cancel the
hosting plan because its for a year term. Any suggestions? -Nick
Reply With Quote
  #2 (permalink)  
Old 06-08-2004
Steven J Sobol
 
Posts: n/a
Default Re: Include troubles...

Nick <nboutelier@hotmail.com> wrote:
> Im having trouble including files from a particular webhost server.
> The webhost won't let me change the php.ini file to set the
> include_path, so ive been trying to work around it with no luck. So
> far ive tried
>
>
> 1. include($_SERVER['DOCUMENT_ROOT'] . "/_includes/menu.php")


This is the most portable way to do it. And in fact, I do it this way
and it should work.

> Unable to access /var/www/html/_includes/menu.php in
> /home/virtual/site136/fst/var/www/html/events/index.php on line 17"


Why is it expanding DOCUMENT_ROOT to /var/www/html? What's your site's URL?

> "Warning: main(/var/www/html/_includes/menu.php): failed to open
> stream: No such file or directory in
> /home/virtual/site136/fst/var/www/html/events/index.php on line 17"




--
JustThe.net Internet & New Media Services, http://JustThe.net/
Steven J. Sobol, Geek In Charge / 888.480.4NET (4638) / sjsobol@JustThe.net
PGP Key available from your friendly local key server (0xE3AE35ED)
Apple Valley, California Nothing scares me anymore. I have three kids.

Reply With Quote
  #3 (permalink)  
Old 06-08-2004
Nick
 
Posts: n/a
Default Re: Include troubles...

Hi Steven, thanks for responding. I guess it adds the "/var/www/html/"
because thats the $_SERVER['DOCUMENT_ROOT']. Thing is that I have not
switched the url, from the old webhost, to point towards the new
webhost, so basically the new site does not have a url only an ip
address. Could this be whats messing up my includes. The webhost is
kind of weird, I cant access it through a direct ip, instead I access
it through (eg. http://66.98.158.6/workingwardrobes.org/events/). I
definitely dont want to switch the url till I know the sites going to
work. I have not had this include problem on any other sites, only
this one. Sure wish I could cancel my hosting plan. Any more
suggestions? -Nick
Reply With Quote
  #4 (permalink)  
Old 06-08-2004
Steven J Sobol
 
Posts: n/a
Default Re: Include troubles...

Nick <nboutelier@hotmail.com> wrote:
> Hi Steven, thanks for responding. I guess it adds the "/var/www/html/"
> because thats the $_SERVER['DOCUMENT_ROOT']. Thing is that I have not
> switched the url, from the old webhost, to point towards the new
> webhost, so basically the new site does not have a url only an ip
> address. Could this be whats messing up my includes.


I'd say that is very likely to be the case. If your web host is giving each
site its own IP address, then you can access the site by IP and get the
proper document_root. If your web host uses one IP for many sites, then
that IP gets you to the first site defined in the web server's configuration
- at least for Apache; other web server programs are different.

> The webhost is
> kind of weird, I cant access it through a direct ip, instead I access
> it through (eg. http://66.98.158.6/workingwardrobes.org/events/).


Ahha, *that* sounds like it's the main issue. Perhaps you could set up
a temporary DNS entry like proto.workingwardrobes.org or
test.workingwardrobes.org and point it at the web server - that way you
don't disrupt the main site. Make sure all of the links on your site are
relative links...

--
JustThe.net Internet & New Media Services, http://JustThe.net/
Steven J. Sobol, Geek In Charge / 888.480.4NET (4638) / sjsobol@JustThe.net
PGP Key available from your friendly local key server (0xE3AE35ED)
Apple Valley, California Nothing scares me anymore. I have three kids.
Reply With Quote
  #5 (permalink)  
Old 06-09-2004
Steven J Sobol
 
Posts: n/a
Default Re: Include troubles...

Steven J Sobol <sjsobol@justthe.net> wrote:

> Ahha, *that* sounds like it's the main issue. Perhaps you could set up
> a temporary DNS entry like proto.workingwardrobes.org or
> test.workingwardrobes.org and point it at the web server - that way you
> don't disrupt the main site. Make sure all of the links on your site are
> relative links...


I should have said "create the temporary DNS entry and have your
web host create a temporary VirtualHost entry for it."

--
JustThe.net Internet & New Media Services, http://JustThe.net/
Steven J. Sobol, Geek In Charge / 888.480.4NET (4638) / sjsobol@JustThe.net
PGP Key available from your friendly local key server (0xE3AE35ED)
Apple Valley, California Nothing scares me anymore. I have three kids.
Reply With Quote
  #6 (permalink)  
Old 06-09-2004
Nick
 
Posts: n/a
Default Re: Include troubles...

Thank you so much Steven for all your help. I hope thats the case. Im
nervous to switch the site url over though when im not positive it
will work because a lot of email accounts would need to be switched
over also. How difficult is it to do the proto.workingwardrobes.org
solution you were talking about? Can I do that even though the
workingwardrobes.org is pointing to the old site. Im assuming id
configure that through the company that registered the url? Thanks
again for your help. -Nick
Reply With Quote
  #7 (permalink)  
Old 06-09-2004
Steven J Sobol
 
Posts: n/a
Default Re: Include troubles...

Nick <nboutelier@hotmail.com> wrote:
> Thank you so much Steven for all your help. I hope thats the case. Im
> nervous to switch the site url over though when im not positive it
> will work because a lot of email accounts would need to be switched
> over also. How difficult is it to do the proto.workingwardrobes.org
> solution you were talking about?


Not difficult, although the hosting company has to do it. Just make sure
your links from pages on your site to other pages on your site are relative,
in the form <A HREF="/path/to/your/page.html"> instead of absolute, in the
form <A HREF="http://www.workingwardrobes.org/path/to/your/page.html">.

Using relative links wherever possible is a good idea even if you don't
have to make a temporary copy of the site...

--
JustThe.net Internet & New Media Services, http://JustThe.net/
Steven J. Sobol, Geek In Charge / 888.480.4NET (4638) / sjsobol@JustThe.net
PGP Key available from your friendly local key server (0xE3AE35ED)
Apple Valley, California Nothing scares me anymore. I have three kids.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:21 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0