Welcome to WebmasterWorld Guest from 54.161.178.52

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Require Once Problem

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

New User

5+ Year Member

joined:May 30, 2007
posts:34
votes: 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,?

8:02 am on June 5, 2007 (gmt 0)

Full Member

10+ Year Member

joined:Aug 3, 2005
posts:269
votes: 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

7:42 pm on June 5, 2007 (gmt 0)

New User

5+ Year Member

joined:May 30, 2007
posts: 34
votes: 0


i know about it, But is there any other way to set timeout or something else
11:30 pm on June 5, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:June 21, 2003
posts:199
votes: 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');

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members