My localhost location is on c:\Web\www\..
In c:\web\www
I have all my pages
In c:\web\scripts
I have all the scripts that import data from different sources
I know it would be best to move scripts to a web directory but for various reasons it is not possible
In the directory c:\web\_include
I would like to create a file that I could include it in all pages and scripts
I have tried with
require ('//web1d01d/web/www/_include/setup_db.php');
('web1d01d' - it's my sever)
But it freezes the server (ability to view pages)
In the scripts directory, there are about 20 different scripts - run at different times.
file setup_db.php
looks like this
<?php
class User {
public function oracle() {
return (object) array(
'login' => 'xxxxx',
'passwd' => 'xxxxx',
'host' => 'xxx.xxx.215.33:1521/yyyy',
'hostspec' => 'xxx.xxx.215.33',
'port' => '1521',
'phptype' => 'oci8',
'service' => 'yyyy'
);
}
public function root() {
return (object) array(
'login'=>'root',
'passwd'=>'xxxxx',
'host'=>'web1d01d'
);
}
public function odbc() {
return (object) array(
'login'=>'xxxxx',
'passwd'=>'yyyyy',
'host'=>'zzzzz'
);
}
};
?>
Perhaps this is because of require
? Is this supposed to be used require_once
instead of it?
You can try the following code snippet.
$doc_root = rtrim ($_SERVER["DOCUMENT_ROOT"], '/') . '/';
require_once($doc_root . '_include/setup_db.php');
<?php
define('DS', DIRECTORY_SEPARATOR);
$path = realpath(dirname(__FILE__). DS .'..'. DS .'_include'. DS .'setup_db.php');
require_once $path;
Try this. Hope it is working fine.
Aaaahh, i'm so stupid :D
I have use this
require_once('c:/web/www/_include/setup_db.php');
And it works perfect for scripts and for web pages... loool
Thank you guys for your help