Necuima Posted October 29, 2013 Share Posted October 29, 2013 Hi, 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 More sharing options...
HartleySan Posted October 29, 2013 Share Posted October 29, 2013 Could you please post the relevant parts of your code, and if possible, a more graphical representation of your file structure? Thank you. Link to comment Share on other sites More sharing options...
Necuima Posted October 29, 2013 Author Share Posted October 29, 2013 Hi HartleySan, Within the highest level directory for the site I have: blog css both directories. Within the blog directory I have a script index.php. Here's its code: <?php // 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"> <head> <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 More sharing options...
Necuima Posted October 30, 2013 Author Share Posted October 30, 2013 Hi, I found that the problem was totally unrelated to the issue described above - somehow my css file was empty! Sorry to have bothered you. Cheers from Oz. Link to comment Share on other sites More sharing options...
HartleySan Posted October 30, 2013 Share Posted October 30, 2013 Good job solving it on your own. Also, thanks for sharing the solution. Link to comment Share on other sites More sharing options...
Recommended Posts