You are here: Re: HTML/PHP include files « HTML « IT news, forums, messages
Re: HTML/PHP include files

Posted by Jon Slaughter on 04/19/07 04:04

<tom_sawyer70@yahoo.com> wrote in message
news:1176940804.995478.237050@o5g2000hsb.googlegroups.com...
>I cannot seem to get a navigation file included for subdocuments on my
> site. I am running SuSE 10 with Apache 2 and PHP. I am new to html,
> php and css, but trying to learn. I'm trying to get this first page
> set to use as a template for the other members.
>
> My css is setup as a two column layout (no tables).
>
> For the following, the files are located under:
> /srv/www/htdocs/index.php
> /srv/www/htdocs/web.css
> /srv/www/htdocs/includes/nav.php
> /srv/www/htdocs/jennifer/jennifer.php
>
> My include path in php.ini has /srv/www/htdocs/includes in it.
>
> My /srv/www/htdocs/index.php file is:
> -----------------------------------------------
> <?php $thisPage='home';?>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
>
> <html>
>
> <head>
> <title>The Family Page</title>
> <link rel="stylesheet" type="text/css" href="web.css" />
> </head>
>
> <body>
>
> <div id="header">
> <h1>The Family</h1>
> </div>
>
> <div id="nav">
> <?php include ('nav.php'); ?>
> </div>
>
> <div id="content">
> <h2>Welcome!</h2>
> <img class="floatright" src="./jennifer/jennifer.jpg" width="90"
> height="120" align="right" alt="Jennifer's Picture" />
> <p>Welcome.</p>
>
> <br></br>
> <br></br>
> <br></br>
>
> <h2>Latest News and Information</h2>
> <p>Improvements to this site.</p>
>
> <h2>What's Coming Soon!</h2>
> <p>More improvements to this site.</p>
>
> </div>
>
> </body>
>
> </html>
> ----------------------------------------
> This file displays correctly and my nav.php is displayed in the left
> panel.
>
> My /srv/www/htdocs/jennifer/jennifer.php file is:
>
> <?php $thisPage='jennifer';?>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
>
> <html>
>
> <head>
> <title>The Family Page</title>
> <link rel="stylesheet" type="text/css" href="../web.css" />
> </head>
>
> <body>
>
> <div id="header">
> <h1>The Family</h1>
> </div>
>
> <div id="nav">
> <?php include ("includes/nav.php"); ?>
> <p>
> </div>
>
>
> <div id="content">
> <h2>Welcome!</h2>
> <img class="floatright" src="jennifer.jpg" width="90" height="120"
> align="right" alt="Jennifer's Picture" />
> <p>Jennifer's page</p>
>
> <br></br>
> <br></br>
> <br></br>
>
> <h2>Latest News and Information</h2>
> <p>Improvements to this site.</p>
>
> <h2>What's Coming Soon!</h2>
> <p>More improvements to this site.</p>
>
> </div>
>
> </body>
>
> </html>
> -----------------------------------------------------
>
> This page does not give an error, displays properly in the css format,
> but the nav.php does not show in the navigation panel. Nor does any
> other php statement (an echo, for example). However, if I put an html
> statement there, it displays in the left panel. My display errors is
> running.
>
> If I try an info.php test file, it displays my server settings.
>
> If I try to adjust the path to the nav.php file with ../nav.php or ../
> nav.php or nav.php (since it is in the include_path), none of them
> work.
>
> I've tried dumping all of the files in the same directory as the
> index.php and changed their paths and I still cannot get anything php-
> related to show in the left panel (where I want the section to show).
>
> All of the files and directories are owned by apache:website and have
> the same permissions.
>
> What am I overlooking or missing to get the php code to work within
> the subfolder file?
>
> TIA.
>

I can't be sure but chances are your paths are wrong.

Whe you do

<?php include ("includes/nav.php"); ?>

You are including w.r.t to the current path

i.e.

/srv/www/htdocs/jennifer/jennifer.php is the file and its looking for
nav.php at
/srv/www/htdocs/jennifer/includes/nav.php

Now if say nav.php is being included but includes inside nav.php still might
be wrong. (such as your style sheets).

I'm currently having a similar issue and trying to find a work around. You
can use absolutely paths but in my case I'm looking at a way that php can
modify the links inside the script.


i.e., in my case I have

root dir---
Index.php
Styles/Main.css
OtherDir/SomePage.php

Somepage.php includes index.php but index.php includes main.css

Now if I load up index.php it all works but when I include index.php into
SomePage.php I only get the contents of index.php but not the style sheet
because its trying to find the style sheet w.r.t to OtherDir instead of the
root dir.

e.g. Somepage loads Index.php as if it copied Index.php to OtherDir but
Index.php is then looking for OtherDir/Styles/Main.css which doesn't.

If you go into Index.php and use ../Styles/Main.css to get it to work with
SomePage then you break it when using Index.php(in most cases).


I cannot use absolute paths for a specific reason but I have yet to find a
solution.

Jon

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация