Jump to content
Larry Ullman's Book Forums

Chapter 3 - Include Multiple Files (Page79)


Recommended Posts

Greetings to all (and especially you Larry)

 

I'm having difficulties getting the CSS to show and I think there is something wrong with my path to CSS.

I like to have things tidy and pretty so I created a subfolder in my www root called "myCMS".

 

FileStructure =

 

myCMS(folder)

index.php

 

assets(folder)

css(folder)

style.css

img(folder)

logo.png

 

includes(folder)

header.html

footer.html

 

I get the includes to work and they show when rendering index.html but there is no styling...

In header.html I have

<link href="assets/css/style.css" rel="stylesheet">

But my greenhord guess is that the path is wrong??

Ideas why CSS wont show?

 

Cheers to all

Link to comment
Share on other sites

I get the includes to work and they show when rendering index.html but there is no styling...

 

 

I do hope you mean index.php or the includes won't work.

 

 

When viewing index.php view the source of the page. Click on the css link in the source. If it doesn't show the css and says something like page not found check the link. Find the stylesheet in the folder and open it in the browser. Compare the two links to check for any errors.

 

Also make sure there are html and head tags, and all tags are closed properly.

Link to comment
Share on other sites

That looks good to me. Just to confirm, you're testing index.php and it's including the header file?

Greetings,

 

Sorry for my late reply! Sorry I made a typo in fist post....off course I ment index.php and yes both header and footer is included and rendered properly in -

http://localhost/myCMS/index.php

 

I now tried to move just the file style.css to the includes folder and changed to -

 

<link href="includes/style.css" rel="stylesheet">

And guess what it works....but why on earth does it not work if I want the CSS to be in assets/css/style.css?

So strange...and making me going nuts.

 

BTW Happy New Year to all!

Link to comment
Share on other sites

When viewing index.php view the source of the page. Click on the css link in the source. If it doesn't show the css and says something like page not found check the link......

 

Hmmm....guess what? Trying to view CSS source with FireFox WebDeveloper plugin gave me a very nice hint..."You do not have permission to access style.css...." Which is strange since I chmoded everything to 777 in frustration.....

Bloody Linux permission denied access to assets folder =) Thanks Ben!

 

 

Case Closed! =)

Link to comment
Share on other sites

  • 3 weeks later...

I seem to have a similar problem. The includes seem to work ok, but the styles do not show when I test index.php. I am doing the exercises on pages 79 to 84 exactly as it says in the book. It seems there is something wrong with the styles. I have saved my website files like so:

Applications/MAMP/htdocs/dynamic/includes. The dynamic folder contains the other webpages from the book, while the includes folder contains footer.html, header.html, index.php and style.css.

The header.html has css linked to it and I have set variable for the page tile and included the header in the index.php as such:

 

$page_title = 'Welcome to this Site!';

include ('includes/header.html');

It still does not work.

How can I make the CSS work? Please help! Thanks :)

Link to comment
Share on other sites

Hi Again!

I finally got the CSS to work (index.php and calculator.php.) However, when I click from the index page to the calculator, I get an error saying:

The requested URL /dynamic/includes/calculator.php was not found on this server.

I have placed the files as described above ie Applications/MAMP/htdocs/dynamic/includes, while the calculator file is in a folder called dynamic. It seems the links in the browser are not connected. How do I get them to be connected to each other ? Hope Larry or someone else sees this. Thank you all...!!

Link to comment
Share on other sites

  • 1 month later...
 Share

×
×
  • Create New...