pete212 Posted April 25, 2009 Share Posted April 25, 2009 Hi, Please can someone help me. This is driving me up the wall! echo $_SESSION['Cart'][0][$y]; $sql="INSERT INTO BASKET (ORDERID, PRODUCTID, PRODUCTNAME, PRICE) VALUES ('$orderid','$_SESSION[Cart][0][$y]','$_SESSION[Cart][1][$y]','$_SESSION[Cart][2][$y]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } All its simply trying to do is read three array positions into a MSQL table. $orderis is inputted sucessfully, but the array data isnt. For PRODUCTID and PRICE i get 0 in the database and for PRODUCTNAME i'm getting Array[1][0]. I know the array is holding the data properly because the echo before the insert echos out the right data! Any help you can give will be much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/155630-inserting-array-into-mysql-db/ Share on other sites More sharing options...
wildteen88 Posted April 25, 2009 Share Posted April 25, 2009 $sql = sprintf("INSERT INTO BASKET (ORDERID, PRODUCTID, PRODUCTNAME, PRICE) VALUES ('%s', '%s', '%s', '%s')", $orderid, $_SESSION['Cart'][0][$y], $_SESSION['Cart'][1][$y], $_SESSION['Cart'][2][$y]); Quote Link to comment https://forums.phpfreaks.com/topic/155630-inserting-array-into-mysql-db/#findComment-819131 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.