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!

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 Integrating with PayPal Building the Shirt Details Page

Jesse Fister
Jesse Fister
11,968 Points

page won't display when I add the paypal form

After adding the paypal form my page will not display when I select a shirt from the shirts page. It is a white screen and the browser page says "localhost/shirt.php?id= 101" When I look in the console it is giving me a server 500 error message. My code is below.

<?php include("inc/products.php"); 

$product_id = $_GET["id"];
$product = $products[$product_id];

$section = "shirts";
$pageTitle = $product["name"];
include("inc/header.php"); ?>

            <div class="section page">

                <div class="wrapper"> 

                    <div class="breadcrumb"><a href="shirts.php">Shirts</a> &gt; <?php echo $product["name"]; ?></div>

                    <div class="shirt-picture">
                            <img src="<?php echo $product["img"]; ?>"  alt="<?php echo $product["name"]; ?>">

                            <div class="shirt-details">

                                <h1><span class="price">$<?php echo $product["price"]; ?></span> <?php echo $product["name"]; ?></h1>

        <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
            <input type="hidden" name="cmd" value="_s-xclick">
            <input type="hidden" name="hosted_button_id" value="<?php echo $product["paypal]"; ?>">
            <input type="hidden" name="item_name" value="<?php echo $product["name"]; ?>">
            <input type="hidden" name="on0" value="Size">
            <label for="os0">Size</label>
            <td><select name="os0" id="os0">
            <option value="Small">Small </option>
            <option value="Medium">Medium </option>
            <option value="Large">Large </option>
            <option value="X-Large">X-Large</option>
            </select> </td></tr>
            <input type="submit" value="Add to Cart" name="submit">

            <p class="note-designer">* All shirts are designed by Mike the Frog.</p>




<?php include("inc/footer.php"); ?> ```

1 Answer

Hi Jesse Fister,

I haven't tested your code, but I am noticing a few lines with un-escaped quotes.


// lines similar to this
<img src="<?php echo $product["img"]; ?>"  alt="<?php echo $product["name"]; ?>">

// need to escape the quotes
<img src="<?php echo $product[\"img\"]; ?>"  alt="<?php echo $product[\"name\"]; ?>">

// or use single quotes
<img src="<?php echo $product['img']; ?>"  alt="<?php echo $product['name']; ?>">

Konrad Pilch
Konrad Pilch
2,435 Points

My images wont display or any code in the products .