When I try to include this file in any of my other pages it doesn't work. Any ideas why? file structure:
index.php
(FOLDER - core) init.php
(FOLDER - functions) sanitise.php
(FOLDER - browse) blog.php , ecommerce.php...
(FOLDER - includes) header.php
The problem I'm having is when I try to include core/init.php in any of my files. Do you spot any mistakes that I've missed or anything?
Maybe its possible to include core/init.php in my includes/header.php file so that when I call includes/header.php in lets say browse/blog.php, core/init.php gets included too. I want init.php to be included in all my web pages.
Init.php code:
<?php
session_start();
$GLOBALS['config'] = array(
'mysql' => array(
'host' => 'localhost',
'username' => 'root',
'password' => 'root',
'db' => 'webAwwards'
),
'remember' => array(
'cookie_name' => 'hash',
'cookie_expire' => 604800
),
'session' => array(
'session_name' => 'user'
)
);
spl_autoload_register(function($class) {
require_once 'classes/' . $class . '.php';
});
require_once '/functions/sanitise.php';
?>
My header.php file code:
<!DOCTYPE html>
<!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
<head>
<!-- Basic Page Needs
================================================== -->
<meta charset="utf-8">
<title>Web Awwards | Web Gallery | Submit your site</title>
<meta name="description" content="">
<meta name="author" content="">
<!-- Mobile Specific Metas
================================================== -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!-- CSS
================================================== -->
<link rel="stylesheet" type="text/css" href="../css/base.css">
<link rel="stylesheet" type="text/css" href="../css/skeleton.css">
<link rel="stylesheet" type="text/css" href="../css/layout.css">
<link rel="stylesheet" type="text/css" href="../css/styles.css">
<link rel="stylesheet" type="text/css" href="../css/menu.css">
<link rel="stylesheet" type="text/css" href="../css/submission.css">
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- Favicons
================================================== -->
<link rel="shortcut icon" href="images/favicon.ico">
<link rel="apple-touch-icon" href="images/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png">
</head>
<body>
<!-- Menu Horizontal -->
<div class="horizontal">
<div class="webName">
<h3>WebA<font style="color: #c14a44;">ww</font>ards</h3>
</div>
<div id='cssmenu' class="twelve columns">
<ul>
<li class='active'><a href="/index.php"><span>Home</span></a></li>
<li class='has-sub'><a href='#'><span>Browse</span></a>
<ul>
<li class='has-sub'><a href='../browse/blog.php'><span>Blog</span></a></li>
<li class='has-sub'><a href='../browse/ecommerce.php'><span>E-Commerce</span></a></li>
<li class='has-sub'><a href='../browse/corporate.php'><span>Corporate</span></a></li>
<li class='has-sub'><a href='../browse/portfolio.php'><span>Portfolio</span></a></li>
<li class='has-sub'><a href='../browse/minimalist.php'><span>Minimalist</span></a></li>
<li class='has-sub'><a href='../browse/other.php'><span>Other</span></a></li>
</ul>
</li>
<li><a href='/login.php'><span>Register/ Login</span></a></li>
<li><a href='/submit.php'><span><font style="color: #68cd7a;">Submit Your Site</font></span></a></li>
</ul>
</div>
</div>
<div class="container">
browse/blog.php code:
<?php
require_once('../core/init.php');
require ('../includes/header.php');
?>
<!-- TODO PHP Scripts -->
<div class="category nine columns">
<div class="category-img">
<img src="/css/img/webImg/screen1.png" alt="Site Description"/>
</div>
<h3> Web Name </h3>
<h5> Designed By: Tautvydas Slegaitis </h5>
<h7> Designers url </h7>
<div class="vote">
<h4> Vote for my site </h4>
</br>
<a href="#"> Love it </a>
<a href="#"> Nope, Not for me </a>
</div>
</div>
</div><!-- Close Container Div -->
<div class="footer">
</div>
</body>
</html>
File does not execute and error is displayed all the time.
Warning: require_once(../core/init.php): failed to open stream: No such file or directory in - on line 2 Fatal error: require_once(): Failed opening required '../core/init.php' (include_path='.:') in - on line 2 "
You are including sanitise.php in wrong way.
/functions/sanitise.php
will search for functions folder in root directory.
You should call it as ../functions/sanitise.php
.