View Full Version : Insert session data into mysql

05-23-2011, 10:53 PM
Into my cart i have a total value which i am trying to insert into a table.

my cart reffering $cartTotal:

$cartTotal="";..$cartTotal=number_format($pricetotal+$cartTotal,2,".","");..$cartTotal="<div align='center'>Cart Total: $".$cartTotal."</div>";

I use a session in page one

$_SESSION['cartTotal'] = $cartTotal;

In my insert page i have this:

$cartTotal=$_SESSION['cartTotal'] ;..$sql="INSERT INTO sales(address,cartTotal) VALUES('$_POST[address]','$cartTotal' )";

and i get an error

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'center'>Cart Total: $300.00
' )' at line 2

05-23-2011, 11:11 PM
i made this and It works great now

the problem was the single quotes on 'center'