Click here to Skip to main content
15,902,198 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using XAMPP and learning from online tutorials, i have only vedio not the source code

this is my directory structor

source file-classes(folder):core.php

source file-emails(folder)

source file-inc(folder):autoload.php,config.php, index.php

source file-pages(folder): index.php

source file-template(folder):_header.php;

the code for config.php
PHP
<?php

if(!isset($_SESSION)){
    session_start();
}

//site domain name with http

 defined"SITE_URL")

|| define("SITE_URL", "http://".$_SERVER['SERVER_NAME']);



//directory separator
defined("DS")|| define("DS", DIRECTORY_SEPARATOR);


// root pat

defined("ROOT_PATH")|| define("ROOT_PATH", realpath(dirname(__FILE__).DS."..".DS));


//classes folder

defined("CLASSES_DIR")|| define("CLASSES_DIR", "classes");

//defined pages

defined("PAGES_DIR")|| define("PAGES_DIR", "pages");

//module folder

defined("MOD_DIR")|| define("MOD_DIR", "mod");

//inc folder

defined("INC_DIR")|| define("INC_DIR", "inc");

//template folder

defined("TEMPLATE_DIR")|| define("TEMPLATE_DIR", "template");



//email path

defined("EMAILS_PATH")|| define("EMAILS_PATH", ROOT_PATH.DS."emails");

//catalogue images path

defined("CATALOGUE_PATH")|| define("CATALOGUE_PATH", ROOT_PATH.DS."catalogue");

//add all above directories to include path

set_include_path(implode(PATH_SEPARATOR, array(
            realpath(ROOT_PATH.DS.CLASSES_DIR),
    realpath(ROOT_PATH.DS.PAGES_DIR),
    realpath(ROOT_PATH.DS.MOD_DIR),
        realpath(ROOT_PATH.DS.INC_DIR),
        realpath(ROOT_PATH.DS.TEMPLATE_DIR),

        get_include_path()



)));
?>

and the code for autoload.php is
PHP
<?php

require_once ('config.php');
function __autoload ($class_name){
    $class = explode ("_",$class_name);
    $path=implode ("/",$class).".php";
    require_once ($path);
}

?>


code for the index.php in the inc folder is
PHP
<?php
require_once('autoload.php');

$core = new Core();

$core->run();

?>



code for the pages(folder) index.php is
PHP
<?php
require_once '_header.php';
?>


when i am running this last index file it show the error,
and the error is
Warning: require_once(_header.php): failed to open stream: No such file or directory in C:\xampp\htdocs\sebastine\pages\index.php on line 5

Fatal error: require_once(): Failed opening required '_header.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\sebastine\pages\index.php on line 5

please some body help me what i am doing wrong my guess is that i am doing some thing wrong in the config files but i can not find it

Thanks
Posted
Updated 27-Apr-14 22:27pm
v2

1 solution

Its right there in the error message - You need to move the file _header.php into the same folder as index.php.

Either that, or you need to properly specify the folder that _header.php lives in.

So, either:
(a) copy _header.php to C:\xampp\htdocs\sebastine\pages\
or
(b) change index.php so that it includes '../template/_header.php' instead of '_header.php'
 
Share this answer
 
Comments
arif_suhail 28-Apr-14 5:04am    
i tried your second solution, first one i did not try cause i know it gonna work and second i dont want to change the location of the header file,

but my question is in the vedio he have just simply type _header.php and it work fine not for me thats what i want to learn, what he did special.

I will acccept your solution tommorow, i will wait for today, not because i want to waste other people time, just i want to try my luck,

and again thanks for help i try your solution second one and work, and i did not know about that so i learn some thing becuase of you
Thanks for your reply
enhzflep 28-Apr-14 5:07am    
You're welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900