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

Charles Franklin
Charles Franklin
17,535 Points

Still Struggling

Anyone able to help me here I'd greatly appreciate it. I've gone over the code multiple times and I cant figure out why i'm getting an error. I have my T-Shirt store built, Paypal buttons created, everything loads fine but when I select a T-Shirt and click Add to Cart I get the following error message from Paypal...

Error Detected

Error Message Some required information is missing or incomplete. Please correct your entries and try again.

Some required information is missing or incomplete. Please correct your entries and try again.

Below is the code I have for my shirt.php file which is the template file that is used to select the T-Shirt... I've gone over the tutorials 3 times and I'm really banging my head against a wall here...

Thanks!

chip

<?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">
                    <span>
                        <img src="<?php echo $product["img"]; ?>" alt="<?php echo $product["name"];?>" >
                    </span>
                </div>

                <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 $product["paypal"]; ?>"> 
                            <input type="hidden" name="item_name" value="<?php echo $product["name"]; ?>">
                                <table>
                                    <tr>
                                        <th>
                                            <input type="hidden" name="on0" value="Size">
                                            <label for="os0">Size</label>
                                        </th>
                                        <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>   
                                </table>        
                            <input type="submit" value="Add to Cart" name="submit">
                        </form>
                    <a class="shirt-designer">*All Shirts are designed by Mike the Frog</a>  
                </div>
            </div>
        </div>

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

3 Answers

You need to add echo to the $product["paypal"]

               you have: <input type="hidden" name="hosted_button_id" value="<?php $product["paypal"]; ?>">


               should be:  <input type="hidden" name="hosted_button_id" value="<?php echo $product["paypal"]; ?>">

If you're getting the error on the PayPal site I would make sure that the PayPal information in your products.php file is set properly, maybe the PayPal values are incorrect? Also on PayPal itself, make sure the product isn't expecting an additional field such as locale or some other setting that might have been set by accident.

Charles Franklin
Charles Franklin
17,535 Points

OMG Kenya... Thank you sooooo much... Works like a charm... I get to go forward... Thank you thank you thank you....

Man, if we'd work together, I'd buy you lunch... whew..

chip

Glad to hear -- good luck.