canadabeeau Posted November 14, 2009 Share Posted November 14, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/181479-solved-require_once-error/ Share on other sites More sharing options...
canadabeeau Posted November 14, 2009 Author Share Posted November 14, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/181479-solved-require_once-error/#findComment-957323 Share on other sites More sharing options...
canadabeeau Posted November 14, 2009 Author Share Posted November 14, 2009 I need some help urgently, am I doing incorect syntax, can someone help please ASAP Quote Link to comment https://forums.phpfreaks.com/topic/181479-solved-require_once-error/#findComment-957337 Share on other sites More sharing options...
canadabeeau Posted November 14, 2009 Author Share Posted November 14, 2009 Does anyone know about the require_once function? Quote Link to comment https://forums.phpfreaks.com/topic/181479-solved-require_once-error/#findComment-957354 Share on other sites More sharing options...
PHPFreaksMaster Posted November 14, 2009 Share Posted November 14, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/181479-solved-require_once-error/#findComment-957356 Share on other sites More sharing options...
canadabeeau Posted November 14, 2009 Author Share Posted November 14, 2009 I have amanaged to figure part of this out I have to enter the dirroot ie C:\inetpub\wwwroot etc but no I keep getting Notice: Undefined index: uri in C:\inetpub\wwwroot\_inc\php\functions.php on line 95 What's this mean Quote Link to comment https://forums.phpfreaks.com/topic/181479-solved-require_once-error/#findComment-957369 Share on other sites More sharing options...
PHPFreaksMaster Posted November 14, 2009 Share Posted November 14, 2009 check your functions.php file you didn't declare $uri variable before using or past your functions.php file code Quote Link to comment https://forums.phpfreaks.com/topic/181479-solved-require_once-error/#findComment-957372 Share on other sites More sharing options...
canadabeeau Posted November 14, 2009 Author Share Posted November 14, 2009 how do I declare the $uri variable before using? $uri = $_GET['uri']; Quote Link to comment https://forums.phpfreaks.com/topic/181479-solved-require_once-error/#findComment-957373 Share on other sites More sharing options...
PHPFreaksMaster Posted November 14, 2009 Share Posted November 14, 2009 You are getting uri from URL, your url must something like this http://localhost/mysite/pagename.php?uri=somevalue if your url is empty I mean is not declared then it will give that error Quote Link to comment https://forums.phpfreaks.com/topic/181479-solved-require_once-error/#findComment-957375 Share on other sites More sharing options...
canadabeeau Posted November 14, 2009 Author Share Posted November 14, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/181479-solved-require_once-error/#findComment-957376 Share on other sites More sharing options...
canadabeeau Posted November 14, 2009 Author Share Posted November 14, 2009 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>"; }; }; Quote Link to comment https://forums.phpfreaks.com/topic/181479-solved-require_once-error/#findComment-957378 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.