jimleeder123 Posted June 8, 2015 Share Posted June 8, 2015 I've got this code: $f = count($_SESSION['checkoutprods']); //brings current number of products in the cart/checkout session for($g=0;$g<$f;$g++) { //gets each order item, so if 2 in checkout, gets the 2 products. Uses the number of items in the sessions above assigned to $f $fproduct[$g] = $_SESSION['transferproducts'.$g.'']; echo "Product Test: "; echo $fproduct[$g]; echo "<br /> <br />"; } The session $_SESSION['checkoutprods'] has whatever products have been processed. So 0 might be Margherita, and 1 might be Ham Pizza. I do a var dump on it, and it has the full names. I echo out "$fproduct[$g]" but it only brings up the first leters of each item in the array (M and H in the example). Any idea how to get the full name? Once I have got this working, it will be inserted into a database table. Quote Link to comment Share on other sites More sharing options...
jimleeder123 Posted June 8, 2015 Author Share Posted June 8, 2015 I have noticed that if I echo the session instead of the variable it echoes the whole name correctly. But how would I put it in this sql statement - $orderitems = "INSERT INTO order_items (order_item_product, order_item_price, order_item_order_id) VALUES ('$fproduct[$g]', '$fprice', '$orderid')"; //mysql_query($orderitems) or die(mysql_error()); No matter what I do, it just brings up errors probably because of the commas etc. Any help please? Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted June 8, 2015 Share Posted June 8, 2015 concatenation of the string $orderitems = "INSERT INTO order_items (order_item_product, order_item_price, order_item_order_id) VALUES ('".$fproduct[$g]."', '".$fprice."', '".$orderid."')"; Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted June 8, 2015 Share Posted June 8, 2015 (edited) Why are you still setting individual transferproducts1, transferproducts2 etc session variables? We have already suggested you not to do this. Maybe you need to look back at Barands code example posted in your previous thread http://forums.phpfreaks.com/topic/296583-auto-incremented-sessions/?p=1512996 have noticed that if I echo the session instead of the variable it echoes the whole name correctly. Can you post what is stored in the session. Show the output of var_dump No matter what I do, it just brings up errors probably because of the commas etc. Any help please? It would be helpful if you could you post all error messages you are getting in full. Edited June 8, 2015 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
jimleeder123 Posted June 8, 2015 Author Share Posted June 8, 2015 I've got it working, thanks QuickOldCar Quote Link to comment 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.