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 trial

PHP Build a Simple PHP Application Creating the Menu and Footer Including the Footer and Adding Additional Pages

Bruce McMinn
Bruce McMinn
10,030 Points

Can't change from hash to file in href

Oh, this is weird. I can't change an href. In the file that I am creating in Sublime Text it is changed, see below:

<html>
<head>
    <title><?php echo "Shirts 4 Mike"; ?></title>
    <link rel="stylesheet" href="css/style.css" type="text/css">
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Oswald:400,700" type="text/css">
    <link rel="shortcut icon" href="favicon.ico">
</head>
<body>

    <div class="header">

        <div class="wrapper">

            <h1 class="branding-title"><a href="./">Shirts 4 Mike</a></h1>

            <ul class="nav">
                <li class="shirts"><a href="shirts.php">Shirts</a></li>
                <li class="contact"><a href="contact.php">Contact</a></li>
                <li class="cart"><a href="#">Shopping Cart</a></li>
            </ul>

        </div>

    </div>

    <div id="content">

However, when I click the link (using MAMP and localhost) I just get localhost/#. When I inspect the element, the code that is revealed has the href as #. The files are in the correct folder I think. That being said, there are two other differences in the code revealed with inspect element. It doesn't show the php code in the <title> line, line 3. And, it includes this data-feedly-mini section in the body that isn't in the code I have typed into Sublime Text. Wha?!!?!

Also, I guess it is worth mentioning that contact.php and shirts.php are identical except for the h1 line. I just copied contact and changed the h1.

alt text

This is driving me a little bonkers. I guess if I was more experienced there is some bug or syntax error detector that would help me narrow down my search...

Ummm, also, when I preview this the image doesn't show up unless I right click it and say open image in another tab. Is there a way to have the image in the post?

1 Answer

Simon Klit
Simon Klit
1,686 Points

Hi Bruce,

First, make sure you've openend the right file, and that you're loading that same file in your browser. If you have multiple index.php's for some reason, check that it's the right one you've opened in Sublime.

Secondly, try clearing your cache for the localhost site (Find out how here: http://superuser.com/questions/721692/google-chrome-clear-cache-for-specific-website).

Also, note that the output you get in the browser will not include any <?php tags or the like. As PHP is a server-sided language, it will all be processed on the server, and only the final HTML will be delivered to the browser.

In regards to the image, you have to direct link to the file. You're simply linking to the Google Drive image viewer. I'm not sure that you can direct link with Google Drive, but you can use this free service for your images: http://www.directlinkupload.com.

Let me know if any of the above solutions work. :)

Bruce McMinn
Bruce McMinn
10,030 Points

Oh man, so embarrassing. I had two header.php files, one in /htdocs and one in /includes. I really thought I had checked that.

Thanks for the info on clearing the cache. And I thought that that was deal with the output, kind of frustrating that it doesn't actually show what you have in the file. Maybe this will make more sense to me in the future.

I'll try the directlinkupload service next time.

Thanks Simon!

Simon Klit
Simon Klit
1,686 Points

Haha! It happens to the best of us ;) Glad you got it fixed.

You're welcome. And, yes, it will most likely make more sense to you as you get to know these languages better. If you want, there's a small blog post on some of the advantages of server-sided languages: http://www.serverschool.com/server-software/advantages-of-server-side-scripting/. It's from 2010, but is still relevant.

Any time, Bruce.