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

Modifying the Model Code - Shirts page not working...

I am on Step 7 of Querying the Database with PHP - Modifying the Model Code, and Randy says that once change the get_products_all() method and comment out the code there and add the new code

    try {
        $results = $db->query("SELECT name, price, img, sku, paypal FROM products ORDER BY sku ASC");
    } catch (Exception $e) {
        echo "Data could not be retrieved from the database.";
        exit;
    }

    $products = $results->fetchAll(PDO::FETCH_ASSOC);    

    return $products;
}

that the shirts page and the search page will still work. For me, the search page is working but the shirts page is just giving me the index of /shirts.

I downloaded his project files and replaced all my code with his and I'm still having the same problem. Could it be a problem with my database?

I am now all the way on the last badge for this course and I have replaced all my code with Randy's for every step and the shirts page and shirts description pages still won't work. Everything else seems to be working fine.

Hi Tricia,

When you say the shirt page isn't working what exactly is/isn't happening? Are you getting any error messages?

2 Answers

Hi Tricia,

If you haven't figured out the problem yet here are the two files that need to be changed. I have changed the file extension from .php to .txt so the server will serve them up. After you download them change the file extensions back.

shirt.php

products.php

Jeff

Hmm... that didn't seem to fix it either. What is different on those files than in the ones in the Project Downloads?

It won't let me reply to your comment above. When I go to www.shirts4mike.com/shirts it just shows me the Index of shirts page with a link to the homepage, /shirt, and /shirts.

can you post your code all of it you are trying to change?

I haven't changed any of the code at all. I downloaded the project files from here: http://treehouse-code-samples.s3.amazonaws.com/PHP/Island03/project03-stage05-shirts4mike.zip and used that. I have the databases in myPHPAdmin on my localhost, and those were both just copied and pasted as well.