Jump to content

Recommended Posts

Hi I have the following code within a file in caleed header.php

 

wwwroot/theme/default/header.php

	session_start();
$require_once = '/_inc/php/functions.php';
require_once($require_once);

 

which is calling functions.php which is located in wwwroot/_inc/php/functions.php

 

can anyone help me figure out why the code above returns the following errors

 

Warning: require_once(/_inc/php/functions.php) [function.require-once]: failed to open stream: No such file or directory in C:\inetpub\wwwroot\theme\default\header.php on line 4

Fatal error: require_once() [function.require]: Failed opening required '/_inc/php/functions.php' (include_path='.;C:\php5\pear') in C:\inetpub\wwwroot\theme\default\header.php on line 4

Link to comment
https://forums.phpfreaks.com/topic/181479-solved-require_once-error/
Share on other sites

I have tried in header.php

 

	session_start();
$require_once = '../../_inc/php/functions.php';
require_once($require_once);

 

with no luck

 

for more info the error occurs when visiting wwwroot/index.php (the one I am testing with for this error, happens on all pages)

 

Warning: require_once(../../_inc/php/functions.php) [function.require-once]: failed to open stream: No such file or directory in C:\inetpub\wwwroot\theme\default\header.php on line 4

Fatal error: require_once() [function.require]: Failed opening required '../../_inc/php/functions.php' (include_path='.;C:\php5\pear') in C:\inetpub\wwwroot\theme\default\header.php on line 4

The error message says that your file path is incorrect I will show some examples:

OK, let say I have my files in a directory(includes) and I want to include files from that directory in a that which is in same place with includes directory.

$file = "includes/header.php";
include($file);

but it would be better to use a condition for checking if file path if ok or not.

$file = "includes/file.php";
if(file_exists($file)){
include($file);
}else{
echo "File not found: $file";
}

 

another example:

Lets say I have a folder named includes and another folder named pages and what I want to do is include file form includes folder in newpage.php which is in pages folder then

$file = "../includes/config.php";
include($file);

 

Hope it helps :)

This is the code I have

 

	$MYSQLI = FUNC_DB_CONNECT();	
$uri = $_GET['uri'];
$FUNC_HEADER_TITLE_QRY = "SELECT * FROM `pages` WHERE `uri`='$uri' LIMIT 1";
$FUNC_HEADER_TITLE_RESULT = $MYSQLI->query($FUNC_HEADER_TITLE_QRY, MYSQLI_STORE_RESULT);
$FUNC_HEADER_TITLE_ARRAY = mysqli_fetch_array($FUNC_HEADER_TITLE_RESULT);
	$FUNC_HEADER_TITLE_VALUE = $FUNC_HEADER_TITLE_ARRAY['title'];
if($uri == "") {
	$title = "AA";
} else {
	$title = "AA ¦ ".$FUNC_HEADER_TITLE_VALUE;
};
echo $title;

 

any suggestions on what I should do?

I get the same error for this PHP function

function FUNC_WELCOME_MESSAGE(){
if($_SESSION['SESS_LOGIN_USERNAME'] == ""){
	echo "Welcome ".FUNC_VISITOR_IP().", to AA. <a href='http://".$_SERVER['HTTP_HOST']."/login/' class='loginout'>Login</a>";
} else {
	echo "Welcome ".$_SESSION['SESS_LOGIN_USERNAME'].", to AA. <a href='http://".$_SERVER['HTTP_HOST']."/login/logout.php' class='loginout'>Logout</a>";
};
};

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.