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 Enhancing a Simple PHP Application Cleaning URLs with Subfolders Using Root-Relative Web Addresses

Problem with link to contact page

I'm doing the "Enhancing A Simple PHP App" and I've been having a lot of problems getting the revised links to work. Most of it I realized was due to the fact that I'm working inside xampp/htdocs, and so the file hierarchy is thrown off a bit. I managed to get my css to load by using "/shirts4mike/css/styles.css", and my shirts and contact page are being linked to like this:

<ul class="nav">
<li class="shirts <?php if ($section == "shirts") { echo "on"; } ?>"><a href="shirts.php">Shirts</a></li>
<li class="contact <?php if ($section == "contact") { echo "on"; } ?>"><a href="contact.php">Contact</a></li>
</ul>

The shirts page loads fine. But when I try to visit the contact page, I get the following error message:

"Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in C:\xampp\htdocs\shirts4mike\contact.php on line 13."

I've been trying to figure it out, but I just can't make sense of it. If someone could help me sort this out, I would really appreciate it.

Thanks!

Hi Ben,

It seems like the link is ok but you have an error in your contact.php page on line 13.

Can you post the first 15 lines or so of contact.php?

Yes, that's the part that is throwing me off. I tried replacing the isset() with something else, but then it simply went on to the next isset() and called an error on that. It seems that my isset functions aren't being accepted, but I have no idea why. Here are the first 20 lines of my contact.php page.

<?php 

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = trim($_POST["name"]);
    $email = trim($_POST["email"]);
    $message = trim($_POST["message"]);


    if ($name == "" OR $email == "" OR $message == "") {
        $error_message = "You must specify a value for name, email address, and message.";
    }

    if (isset(!$error_message)) {
            foreach( $_POST as $value ){
            if( stripos($value,'Content-Type:') !== FALSE ){
                $error_message = "There was a problem with the information you entered.";    
            }
        }
    }

Thanks, Jason.

1 Answer

I think you've misplaced the !

Try this: if (!isset($error_message)) {

You want to check if the $error_message variable is set or not and then negate the result of that.

That was totally it. I can't believe I overlooked that. Thanks, man!