Jump to content

Recommended Posts

I am following along with a "php solutions dynamic web design made easy" book.  I am trying to get a php includes file to work with an index.php file.  I am doing all of this on my mac as localhost.  I have php installed and python running.  I am using bbedit to write and edit the files.  Any help would be much appreciated.  The navigation is simply not showing up in the left hand side, making me think that the php includes is not working properly.

 

The index.php is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Japan Journey</title>

<link href="assets/journey.css" rel="stylesheet" type="text/css" media="screen" />

</head>

 

<body>

<div id="header">

    <h1>Japan Journey </h1>

</div>

<div id="wrapper">

    <?php include('includes/menu.inc.php'); ?>

    <div id="maincontent">

        <h1>A journey through Japan with PHP </h1>

<p>Ut enim ad minim veniam, quis nostrud exercitation consectetur adipisicing elit. Velit esse cillum dolore ullamco laboris nisi in reprehenderit in voluptate. </p>

<div id="pictureWrapper"><img src="images/basin.jpg" alt="Water basin at Ryoanji temple" width="350" height="237" class="picBorder" /></div>

        <p>Eu fugiat nulla pariatur. Ut labore et dolore magna aliqua. Cupidatat non proident, quis nostrud exercitation ut enim ad minim veniam.</p>

        <p> Lorem ipsum dolor sit amet, ut enim ad minim veniam, consectetur adipisicing elit. Duis aute irure dolor ut aliquip ex ea commodo consequat.</p>

        <p>Sed do eiusmod tempor incididunt velit esse cillum dolore ullamco laboris nisi.</p>

    </div>

    <div id="footer">

    <p>© 2006 David Powers</p>

    </div>

</div>

</body>

</html>

 

and the menu.inc.php in the includes folder is:

<ul id="nav">

        <li><a href="index.php" id="here">Home</a></li>

        <li><a href="journal.php">Journal</a></li>

        <li><a href="gallery.php">Gallery</a></li>

        <li><a href="contact.php">Contact</a></li>

    </ul>

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/54398-php-includes-not-working/
Share on other sites

change this:

<ul id="nav">
        <li><a href="index.php" id="here">Home[/url]</li>
        <li><a href="journal.php">Journal[/url]</li>
        <li><a href="gallery.php">Gallery[/url]</li>
        <li><a href="contact.php">Contact[/url]</li>
    </ul>

 

To this:

 

<ul id="nav">
        <li><a href="index.php" id="here">Home</a></li>
        <li><a href="journal.php">Journal</a></li>
        <li><a href="gallery.php">Gallery</a></li>
        <li><a href="contact.php">Contact</a></li>
    </ul>

 

Now what is the error showed there by php.

Yes, sorry the /quote is not there in my code.  I am not getting any errors...or at least I don't think so.  How can I check?  This code was mainly written by a tutorial.  All I did was cut and paste the ul into a menu.inc.php in an includes folder.  After doing this the Ul does not show up when loading the index.php in firefox.

<?php
error_reporting(E_ALL); 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Japan Journey</title>
<link href="assets/journey.css" rel="stylesheet" type="text/css" media="screen" />
</head>

<body>
<div id="header">
    <h1>Japan Journey </h1>
</div>
<div id="wrapper">
    <?php include('includes/menu.inc.php'); ?>
    <div id="maincontent">
        <h1>A journey through Japan with PHP </h1>
      <p>Ut enim ad minim veniam, quis nostrud exercitation consectetur adipisicing elit. Velit esse cillum dolore ullamco laboris nisi in reprehenderit in voluptate. </p>
      <div id="pictureWrapper"><img src="images/basin.jpg" alt="Water basin at Ryoanji temple" width="350" height="237" class="picBorder" /></div>
        <p>Eu fugiat nulla pariatur. Ut labore et dolore magna aliqua. Cupidatat non proident, quis nostrud exercitation ut enim ad minim veniam.</p>
        <p> Lorem ipsum dolor sit amet, ut enim ad minim veniam, consectetur adipisicing elit. Duis aute irure dolor ut aliquip ex ea commodo consequat.</p>
        <p>Sed do eiusmod tempor incididunt velit esse cillum dolore ullamco laboris nisi.</p>
    </div>
    <div id="footer">
    <p>© 2006 David Powers</p>
    </div>
</div>
</body>
</html>

 

Try that and see if you get any error messages.

Ok try this

 

<?php
error_reporting(E_ALL); 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Japan Journey</title>
<link href="assets/journey.css" rel="stylesheet" type="text/css" media="screen" />
</head>

<body>
<div id="header">
    <h1>Japan Journey </h1>
</div>
<div id="wrapper">
    <?php include('includes/menu.inc.php') or DIE("Could not include file"); ?>
    <div id="maincontent">
        <h1>A journey through Japan with PHP </h1>
      <p>Ut enim ad minim veniam, quis nostrud exercitation consectetur adipisicing elit. Velit esse cillum dolore ullamco laboris nisi in reprehenderit in voluptate. </p>
      <div id="pictureWrapper"><img src="images/basin.jpg" alt="Water basin at Ryoanji temple" width="350" height="237" class="picBorder" /></div>
        <p>Eu fugiat nulla pariatur. Ut labore et dolore magna aliqua. Cupidatat non proident, quis nostrud exercitation ut enim ad minim veniam.</p>
        <p> Lorem ipsum dolor sit amet, ut enim ad minim veniam, consectetur adipisicing elit. Duis aute irure dolor ut aliquip ex ea commodo consequat.</p>
        <p>Sed do eiusmod tempor incididunt velit esse cillum dolore ullamco laboris nisi.</p>
    </div>
    <div id="footer">
    <p>© 2006 David Powers</p>
    </div>
</div>
</body>
</html>

 

Also make sure that relative to the script the menu.inc.php is in the includes DIR.

Ok, let's try this then:

 

menu.inc.php

<script>alert("We have Lift Off!!!");</script>
<ul id="nav">
        <li><a href="index.php" id="here">Home</a></li>
        <li><a href="journal.php">Journal</a></li>
        <li><a href="gallery.php">Gallery</a></li>
        <li><a href="contact.php">Contact</a></li>
    </ul>

 

See if you get the javascript popup.

here is some of the css

 

#nav {

    position: absolute;

    top: 140px;

    left: 60px;

    width: 90px;

}

ul#nav {

    list-style: none;

    margin: 0;

    padding: 0;

}

#nav a {

    display: block;

    width: 100px;

    padding-left: 10px;

    margin: 3px 0;

    text-decoration: none;

    font-family: Geneva, Arial, Helvetica, sans-serif;

    font-variant: small-caps;

    font-weight: bold;

}

#nav a:link, #nav a:visited {

    border-left: #00425E solid 10px;

    color: #00425E;

}

 

#nav a:hover, #nav a:active {

    border-left-color: #fff;

    background-color: #00425E;

    color: #fff;

}

here is some of the css

 

#nav {

    position: absolute;

    top: 140px;

    left: 60px;

    width: 90px;

}

ul#nav {

    list-style: none;

    margin: 0;

    padding: 0;

}

#nav a {

    display: block;

    width: 100px;

    padding-left: 10px;

    margin: 3px 0;

    text-decoration: none;

    font-family: Geneva, Arial, Helvetica, sans-serif;

    font-variant: small-caps;

    font-weight: bold;

}

#nav a:link, #nav a:visited {

    border-left: #00425E solid 10px;

    color: #00425E;

}

 

#nav a:hover, #nav a:active {

    border-left-color: #fff;

    background-color: #00425E;

    color: #fff;

}

 

You won't get much help on the PHP HELP forum, post that over in ther CSS forum, that is where those gurus live.

Alright, I decided to ditch the tutorial and make an index.php and a menu.inc.php in a folder called includes in the Sites directory on my mac.  I used BBedit to make these files.  I was still unsuccessful getting the includes to show up.

 

the index.php is:

<body>

<ul><?php include('includes/menu.inc.php') ?></ul>

 

 

hello

 

</body>

 

and the menu.inc.php in the "includes" folder is

<li><a href="index.php" id="here">Home</a></li>

<li><a href="journal.php">Journal</a></li>

 

Shouldn't this work?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.