Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBen Os
20,008 PointsMy catalog items appear as a long list and suddenly there is no CSS in the site
I am doing the third PHP course and bulding my first non-cms PHP site. I have a very minimalist code (thanks to Alina Holligan) and I seem to did everything right so there are no PHP errors; Till now I also didn't have any CSS-related problems and this is the first time such a thing happens:
For some reason my catalog items appear as a long list and there is no CSS in the site.
Edit: Here are all my codes in one segment:
And here is a link to my Treehouse site:
4 Answers
Dani Bachour
Courses Plus Student 1,977 PointsYou forgot to include("inc/header.php"); inside your index.php
elk6
22,916 PointsHi Ben,
I do not see any link to your CSS sheet in there. So the HTML will be styled without it. It probably belongs in your header.php file ( although not sure, did not take this course yet ) so be sure to check for it.
Ben Os
20,008 PointsHi Elian, I've updated the Q with a little bit more data. I also expanded about the fact that till now I didn't have any special link to the CSS (not something I noticed) and this is a very new problem. Can you see the further details I added and give me an advice?
elk6
22,916 PointsCan you do me a favor, Ben? Can you snapshot your workspace and post the link here? It's the arrow icon in the top right corner next to the preview button. We will be able to see everything from there and will be able to give you a better solution.
Thanks!
Ben Os
20,008 PointsOh, thank you Elian, I didn't know this option existed... That's why I copied all this text, Thank you very much for telling me about this!!! Here it is:
Ben Os
20,008 PointsIn case you didn't see the notification \ We published in the same time - Bumping.
samtruss1986
11,772 PointsHi Ben, I hope you got your issue resolved.
When you put the catalog.php file within a sub-directory then the css and img also fail.
I was wondering if there was any code that I would have to modify for this to work.
I have tried the standard ../ beforehand, but the inc file is meant to contain files for a whole site and many large sites have sub directories.
Thank you.
Brian Gilligan
1,540 PointsI had this same issue! It took me forever to find out what was causing it! When I downloaded the data.php file and cut and pasted it in, it didn't include the <?php tag on line 1. Once I added this to the top of the data.php file, it worked again! I hope this helps! Example: <?php //<---THIS IS WHAT WAS MISSING $catalog[101] = [ "title" => "A Design Patterns: Elements of Reusable Object-Oriented Software", "img" => "img/media/design_patterns.jpg", "genre" => "Tech", "format" => "Paperback", "year" => 1994, "category" => "Books",
Ben Os
20,008 PointsBen Os
20,008 PointsGiven that till now all css work I think I deleted this by mistake... Wouldn't it be better to put the link to the css file in Index.php always?
Much thanks for you help!
Dani Bachour
Courses Plus Student 1,977 PointsDani Bachour
Courses Plus Student 1,977 PointsNo, it won't. index.php is independent file. header.php is a general file which is used to include CSS (and maybe JavaScript later) into the main web site pages.