Jump to content

Problems with require_once


maometto

Recommended Posts

I am working on a php application where all the files of the application are under the folder 'Sharp Version'.

In this folder, there r 2 folders 'common' and 'admin' and also some php files.

 

In the main folder 'Sharp Version', there is a file called 'settingshandler.php'. This file is required by all files in all the folders.

 

In the folder common, there is a file called class_database_handler.php that requires settingshandler.php. Here is the problem, if i want to run any files from the admin folder, the require statement should be as such require_once('../settingshandler.php') and the files run normally but the files from the main folder 'Sharp Version' do not run. If the statement is changed to require_once('./settingshandler.php') then the files from the main folder run but those from admin folder no longer run.

 

and this is the error msg that I get..

 

Warning: require_once(../settingshandler.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\Sharp Version\common\class_database_handler.php on line 15

 

Fatal error: require_once() [function.require]: Failed opening required '../settingshandler.php' (include_path='.;C:\php5\pear') in C:\wamp\www\Sharp Version\common\class_database_handler.php on line 15

 

*** Other notes

My include path is

; UNIX: "/path1:/path2"

;include_path = ".:/php/includes"

;

; Windows: "\path1;\path2"

;include_path = "..;c:\php\includes;c:\wamp\www"

 

Following is some code from class_database_handler.php.

 

require_once("../settingshandler.php");

require_once "class_database_ops.php";

 

############################################################################

/** class for database handling. */

class Database_handler extends Database_ops

{

// DB Connection object

var $db_conn;

 

/** Constructors and Destructors */

function Database_handler()

{

// Create the connection to the DB

parent::Database_ops();

$db_conn = parent::db_connect();

}

 

function __destruct()

{

    // Disconnect from the DB and close the connection

   

    $close = parent::db_close($db_conn);

}

 

 

function readSelectOptions ($col_name)

{

// Access DB table "dropdown" and column $col_name and store in array all values of that column and return array

// If null or empty data don't add to array

$arr = array();

$result = parent::db_query("SELECT $col_name FROM dropdown");

while ($row = parent::db_fetch_array_both($result)) {

if (($s = $row[$col_name]) != "")

array_push($arr, $s);

}

return $arr;

}

}

Link to comment
https://forums.phpfreaks.com/topic/38916-problems-with-require_once/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.