Jump to content

DOCUMENT_ROOT help needed


spires

Recommended Posts

Hi

 

I have this bit of code:

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

 

That i'm using so all systems can always find my class and important files.

 

This works fine on on of my websites, but I have just moved it over to another website (exact setup & on same server) and it is not working!!!

 

 

I'm getting the error:

Warning: require_once(/includes/functions.php) [function.require-once]: failed to open stream: No such file or directory in /home/a/d/adele/web/public_html/includes/initialize.php on line 9

 

Fatal error: require_once() [function.require]: Failed opening required '/includes/functions.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/a/d/adele/web/public_html/includes/initialize.php on line 9

 

 

Basically, all my important files are in the initialize.php file. So I only need to call that one file on any of

my html pages.

 

 

I know it's DOCUMENT_ROOT, as when I remove this and link direct it works fine.

 

Thanks for any help

 

:)

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/223556-document_root-help-needed/
Share on other sites

Yes:

 

initialize.php:

<?PHP

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


require_once(LIB_PATH.DS."config.php");
require_once(LIB_PATH.DS."functions.php");


// core objects
require_once(LIB_PATH.DS."session.php");
require_once(LIB_PATH.DS."database.php");
require_once(LIB_PATH.DS."pagination.php");
require_once(LIB_PATH.DS."PHPMailer".DS."class.phpmailer.php");
require_once(LIB_PATH.DS."PHPMailer".DS."class.smtp.php");


// related classes
require_once(LIB_PATH.DS."profile_user.php");
require_once(LIB_PATH.DS."blog.php");
require_once(LIB_PATH.DS."blog_img_signup.php");
require_once(LIB_PATH.DS."blog_categories.php");



?>

 

 

In HTML file

require_once("../../../includes/initialize.php");

Yes what? There is nothing there that puts any paths on your include path.

 

How about....

 

<?php

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

set_include_path(get_include_path() . PATH_SEPARATOR . LIB_PATH);

require_once("config.php");
require_once("functions.php");


// core objects
require_once("session.php");
require_once("database.php");
require_once("pagination.php");
require_once("PHPMailer".DS."class.phpmailer.php");
require_once("PHPMailer".DS."class.smtp.php");

 

Then instead of....

 

require_once("../../../includes/initialize.php");

 

which should have been....

 

require_once(LIB_PATH.DS."initialize.php");

 

anyway shouldn't it?

 

You can now use....

 

require_once("initialize.php");

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.