Welcome to WebmasterWorld Guest from 184.73.3.107

Forum Moderators: coopster & jatar k

Require Once Problem

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

5+ Year Member



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 Jun 5, 2007 (gmt 0)

5+ Year Member



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 Jun 5, 2007 (gmt 0)

5+ Year Member



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

10+ Year Member



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');

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month