Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2011
    Posts
    95
    Thanks
    13
    Thanked 1 Time in 1 Post

    Insert session data into mysql

    Into my cart i have a total value which i am trying to insert into a table.

    my cart reffering $cartTotal:

    PHP Code:
    $cartTotal="";..$cartTotal=number_format($pricetotal+$cartTotal,2,".","");..$cartTotal="<div align='center'>Cart Total: $".$cartTotal."</div>"
    I use a session in page one
    PHP Code:
    $_SESSION['cartTotal'] = $cartTotal

    In my insert page i have this:
    PHP Code:
    $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

  • #2
    New Coder
    Join Date
    Apr 2011
    Posts
    95
    Thanks
    13
    Thanked 1 Time in 1 Post
    i made this and It works great now
    $cartTotal="$".$cartTotal."";

    the problem was the single quotes on 'center'


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •