scuttzz Posted February 28, 2014 Share Posted February 28, 2014 hi, First off this cart mentioned below is for a online cart and works perfectly on a local server such as xammp, how ever when i up load it to a live server it all the variables in the cart out throws errors. Has anyone encounter this problem? Heres my code for the cart render: <?php $cartOutput = ""; $cartTotal = ""; $pp_checkout_btn = ''; $product_id_array = ''; if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) { $cartOutput = "<h2 align='center'>Your shopping cart is empty</h2>"; } else { // Start PayPal Checkout Button $pp_checkout_btn .= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="upload" value="1"> <input type="hidden" name="business" value="you@youremail.com">'; // Start the For Each loop $i = 0; foreach ($_SESSION["cart_array"] as $each_item) { $item_id = $each_item['item_id']; $sql = mysql_query("SELECT * FROM products WHERE id='$item_id' LIMIT 1"); while ($row = mysql_fetch_array($sql)) { $product_name = $row["product_name"]; $price = $row["price"]; } $pricetotal = $price * $each_item['quantity']; $cartTotal = $pricetotal + $cartTotal; $pricetotal = $pricetotal; // Dynamic Checkout Btn Assembly $x = $i + 1; $pp_checkout_btn .= '<input type="hidden" name="item_name_' . $x . '" value="' . $product_name . '"> <input type="hidden" name="amount_' . $x . '" value="' . $price . '"> <input type="hidden" name="quantity_' . $x . '" value="' . $each_item['quantity'] . '"> '; // Create the product array variable $product_id_array .= "$item_id-".$each_item['quantity'].","; // Dynamic table row assembly $cartOutput .= ' <div style="width:46%;border:1px solid #99FFFF;background:#99FFFF;float:left;margin-top:10px;margin-left:9px;margin-right:5px;border-radius:10px;padding:5px;"> <div style="float:left;width:90%;font:bold 16px Arial;">' . $product_name . '</div> <div style="float:left;width:5%;font:bold 16px Arial;float:right;"> <form action="cart.php" method="post"><input style="border:none;background:none;font-size:15px;" name="deleteBtn' . $item_id . '" type="submit" value="X" /><input name="index_to_remove" type="hidden" value="' . $i . '" /></form> </div> <h4 style="margin-top:5px;"><u>Purchase Details</u></h4> <table style="margin-top:5px;width:90%;"> <tr> <td width="40%">Unit Price: </td> <td>R' . $price . '</td> </tr> <tr> <td width:60%;height:20px;border:1px solid black;>Quantity</td> <td> <form action="cart.php" method="post"> <input name="quantity" type="text" value="' . $each_item['quantity'] . '" size="1" maxlength="2" /> <input name="adjustBtn' . $item_id . '" type="submit" value="change" /> <input name="item_to_adjust" type="hidden" value="' . $item_id . '" /> </form> </td> </tr> <tr> <td width:60%;height:20px;border:1px solid black;>Total</td> <td>R' . $pricetotal . '</td> </tr> </table> </div> '; $i++; } $cartTotal = $cartTotal; // Finish the Paypal Checkout Btn $pp_checkout_btn .= '<input type="hidden" name="custom" value="' . $product_id_array . '"> <input type="hidden" name="notify_url" value="https://www.yoursite.com/storescripts/my_ipn.php"> <input type="hidden" name="return" value="https://www.yoursite.com/checkout_complete.php"> <input type="hidden" name="rm" value="2"> <input type="hidden" name="cbt" value="Return to The Store"> <input type="hidden" name="cancel_return" value="https://www.yoursite.com/paypal_cancel.php"> <input type="hidden" name="lc" value="US"> <input type="hidden" name="currency_code" value="USD"> <input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - its fast, free and secure!"> </form>'; }?> This script obviously contains a paypal check out system so ignore it if it makes it easier.. Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/286602-no-errors-while-testing-on-a-local-server-variable-errors-when-live-help-please/ Share on other sites More sharing options...
WebStyles Posted February 28, 2014 Share Posted February 28, 2014 (edited) this is the same as your previous post called 'undefined Var Errors' and it seems you didn't even bother to try the things we suggested at the time. for example, you're still doing this: $sql = mysql_query("SELECT * FROM products WHERE id='$item_id' LIMIT 1"); while ($row = mysql_fetch_array($sql)) { after I have explained to you that looping through results when you know there's only going to be one (LIMIT 1) is silly. Edited February 28, 2014 by WebStyles Quote Link to comment https://forums.phpfreaks.com/topic/286602-no-errors-while-testing-on-a-local-server-variable-errors-when-live-help-please/#findComment-1471024 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.