2

I know this question has been asked before, but even after reading other posts I can't figure out whats going on...

Please have a look at my code structure and see what am I doing wrong..

Folder structure:

index.php

(FOLDER - Includes) header.php

(FOLDER - browse) blog.php , ecommerce.php, other.php

(FOLDER - core) init.php

I'm trying to include Header.php from includes folder in blog.php in browse folder. Below is my header.php code.

Header file located in Includes folder

    <!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>
<?php
    require_once('core/init.php');
?>
<!-- Menu Horizontal -->
<div class="horizontal">
    <div class="webName">

and Browse folder blog.php file code:

<?php
    include './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>

But it is not working. I dont know why,... Please please help me sort this out its killing me for the past 2 days. Coda 2 is showing me an error

" Warning: include(./includes/header.php): failed to open stream: No such file or directory in - on line 2 Warning: include(): Failed opening './includes/header.php' for inclusion (include_path='.:') in - on line 2 "

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'

    )
);
// TODO Remove parenthesis in require once if doesnt work
spl_autoload_register(function($class) {
    require_once('classes/' . $class . '.php');
});

require_once('/functions/sanitise.php');

?>
4
  • 1
    ./ should be ../. Commented Feb 15, 2014 at 11:13
  • if I add ../ it includes the header but then stops executing the rest of blog.php and if I view source code in the browser only shows header.php code Commented Feb 15, 2014 at 11:19
  • Try using require instead of include. Commented Feb 15, 2014 at 11:20
  • if I use require it doesnt change anything. I'm really out of ideas no idea whats going on Commented Feb 15, 2014 at 11:23

3 Answers 3

3

try :

include('../test/header.php');

it works fine in me.

Edit: and if not on your case, try to correct the path of your init.php:

require_once('../core/init.php');
Sign up to request clarification or add additional context in comments.

6 Comments

if i correct the path of my init.php as you suggested none of the files open then. I know it would make sense but I dont know why this is happening
have you tried to remove it first just to check if you can already check get include('../test/header.php'); correctly?
Right so the problem is then with the include of init.php in the header :)
But how could I make it so it includes in all sort of different directories then>? Whether it be in main index.php and browse/blog.php
instead of using require_once, can you also try include on init.php and see what will happen?
|
0

You could try something like:

include $_SERVER['DOCUMENT_ROOT'] .'*/project_name_if_needed*/test/header/';

I don't know if this is recommended, so use with caution.

Comments

0

I had the same issue and finally discovered that OVH deactivates the option allow_url_include on their shared web servers by default. This is a general setting that can not be changed.

The solution is to use something like

require ($_SERVER['DOCUMENT_ROOT'].'/wp-config.php');

as Lucas said.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.