Skip to main content
Inspiring
February 15, 2007
Answered

css and php include

  • February 15, 2007
  • 1 reply
  • 543 views
I have a dreamweaver template which has the following include to a php file in the first few lines.

<?php
include "../public_html/code/db.php";
?>

The template also includes a couple of css style sheets of the format

<link href='../public_html/css/na_style_scr.css' rel='stylesheet' type='text/css' media='screen'>

When I save documents from this template in different folders of the site, the include link was not updating, so I updated teh template as below

<?php
include ("../../code/db.php");
?>

Now the documents can be saved anywhere in the site and the link is correct, but when I view the document in dreamweaver, the file appears as though there is no stylesheet. The file appears correct on the testing server.

Has anyone come accross this before, or can anyone suggest a solution to this?

Many thanks

Patch
This topic has been closed for replies.
Correct answer Patch
Thanks for these tips.

I now have found a solution to the problem of Dreamweaver not displaying the CSS layout of the page. Originally I had my

<?php
include ("../code/db.php");
?>

code as the first line of the <head> tag.

By moving this so that it now appears before the <html> tag, and making including the following tag

<!-- TemplateInfo codeOutsideHTMLIsLocked="true" -->

The problem now seems to be by-passed.

Not sure why, but as it works, I don't really mind.

Thanks for the input.

1 reply

Inspiring
February 15, 2007
Its best to use a full server path for your PHP, ie the path using the
server filesystem.

For the css you have:

<link href='../public_html/css/na_style_scr.css' rel='stylesheet'
type='text/css' media='screen'>

you shouldnt have public_html, it should be a root relative link

<link href='/css/na_style_scr.css' rel='stylesheet'
type='text/css' media='screen'>


--
Gareth
http://www.phploginsuite.co.uk/
PHP Login Suite V2 - 34 Server Behaviors to build a complete Login system.


PatchAuthor
Inspiring
February 15, 2007
Thanks for the tip Gareth, I have now changed this, but am still getting this rendering problem.

Having created a page from the template, if I then detach it from the template and edit the php include, so that I change it from

include ("/code/db.php");

to

include "code/db.php";

then all of a sudden the styles are visible again.

Can anyone esle shed any light on this. I't got me scratching my head in confusion!!

Thanks