homepage Welcome to WebmasterWorld Guest from 54.226.173.169
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Require Once Problem
umerkk




msg:3358822
 7:46 am on Jun 5, 2007 (gmt 0)

Hi

I Have a php file name ss.php and it is included on every page of my Website, and on that file is included a file name Connections/Rac.php

so my code looks like

require_once('http://localhost/rac/Connections/Rac.php');

I cannot Make it ../../rac/Connections/Rac.php because this page is included in all my web pages which are also in sub folder and so on, So sometimes it says Failed to open stream, because of Bad path, and when i uploaded this site on Netfrims Hosting, It says Internal Server 500 error and when i contacted them they said if you are using PHP Script to acccess file outside domain then you should give some timeout thing, and probably the prob is timeout, When i uploaded the site, i changed the localhost to my domain name

My Questions is, that is there any other Good way to solve this prob,?

 

Scally_Ally




msg:3358839
 8:02 am on Jun 5, 2007 (gmt 0)

You could try using the server variable $_SERVER['HTTP_HOST'] so that wherever you move you site to it will still work.

require_once($_SERVER['HTTP_HOST'].'/rac/Connections/Rac.php');

Ally

umerkk




msg:3359393
 7:42 pm on Jun 5, 2007 (gmt 0)

i know about it, But is there any other way to set timeout or something else

sabai




msg:3359538
 11:30 pm on Jun 5, 2007 (gmt 0)

The best way to do what you are wanting to do is to put the directory the file you are trying to include on the include path. Update the include_path option either in .htaccess, httpd.conf or programatically with ini_set(). You can then include the file from any PHP script anyplace.


e.g.

ini_set( 'include_path', ini_get('include_path') . DIRECTORY_SEPARATOR . '/home/myuser/libs/rac/' );

include_once('Connections/Rac.php');


Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved