Jump to content
Larry Ullman's Book Forums

Recommended Posts



On page 90 of the book, guidance is given on relative file referencing. I am currently trying to work out why a file reference that I am trying to use does not work.


Here's the scenario:


The highest level directory contains a sub-directory named css and also one called blog.


In the blog directory I have several scripts. Let's start with the index.php script (within the blog directory). It includes a file './blog_header.htm' which gets included OK.


But './blog_header.htm' then tries to include a css file which is in the highest level directory via '../css/filename.css'. But when I use debug I can see that the css file is not included and the link (via debug) shows only one period, not the two in the include statement.


Any help will be most appreciated.


With thanks, Necuima.

Link to comment
Share on other sites

Hi HartleySan,


Within the highest level directory for the site I have:





both directories.


Within the blog directory I have a script index.php.

Here's its code:


// this is the blog page
require_once ('../get_dbc.php');  // establish the connection to the database

$page_title = "Screen Title";

require ('./blog_header.htm');  // this includes the opening <head> and closing </head> statements  

require ('./blog_header_data.htm');  // common header data - this includes the opening <body> tag



As mentioned above, ./blog_header.htm gets included OK (I can see that from debug).


Then ./blog_header.htm tries to include some css from the css directory as follows:

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

<!-- saved from url=(0014)about:internet -->

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


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

 <title><?php echo $page_title; ?></title>

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

    <link rel="stylesheet" type="text/css" href="./blog.css" media="screen" /> etc...

You can see that the include for the css file has the ../ start so I was assuming that it would go up one directory level then go to the css directory to include the filename.css css.  But when I look at it with (IE10) debug, the css file is not included and the code shows only one period - i.e. ./css/filename.css - somehow the two period control gets ignored.


Again, any guidance will be most appreciated.


Thanks from Oz, Necuima.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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