Search code examples
phppathdefined

Why does php reports "failed to open stream" with Directory Separator Defined?


I have a web directory at C:\xampp\htdocs\Dove\Subsediaries\drugs. I have defined directory separator. Please what else could be missing because the script isn't running. Gratitude!

defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR);  
defined('SITE_ROOT') ? null : define ('SITE_ROOT', $_SERVER['DOCUMENT_ROOT'].DS.'drugs');  
defined('LIB_PATH') ? null : define ('LIB_PATH',SITE_ROOT.DS.'includes');  

// load config file first   
require_once(LIB_PATH.DS."config.php");  
//load basic functions next so that everything after can use them  

require_once(LIB_PATH.DS."functions.php");  
require_once(LIB_PATH.DS."session.php");  
require_once(LIB_PATH.DS."tbldrugs.php");  
require_once(LIB_PATH.DS."tblmsg.php");  
require_once(LIB_PATH.DS."users.php");  


//Load Core objects  
require_once(LIB_PATH.DS."database.php");  

//load database-related classes  

Solution

  • Thanks. I just figured out the reason from a similar post at How do i use the DIRECTORY_SEPARATOR for Windows . I corrected the SITE_ROOT definition with

     defined('SITE_ROOT') ? null : define('SITE_ROOT', 'C:'.DS.'xampp'.DS.'htdocs'.DS.'Dove'.DS.'Subsediaries'.DS.'drugs');
    

    and everything is working well now. Thanks http://www.Stackoverflow.com !