Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2008
    Posts
    4

    Exclamation Unanswered: trying to write shopping cart function (was "please HELP")

    i upload my sql file to serer and when i do i get this error


    Error
    SQL query:

    FUNCTION writeShoppingCart(

    ){$cart = $_SESSION[ 'cart'];



    MySQL said:

    #1064 - 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 'function writeShoppingCart() {
    $cart = $_SESSION['cart']' at line 1

    please help i am a newbie so i just need some help and some tips

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    FUNCTION is not a mysql command

    what are you trying to do?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Apr 2008
    Posts
    4
    my shopping cart

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    okay, you cannot do it that way
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Apr 2008
    Posts
    4
    so maybe you can help me with that

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    looks like PHP to me.. so I'll move it to the PHP forum
    to diagnose what is going wrong will require the preceeding lines (just the immediae 2..or 3 lines, not the whole script)

    on the face of it the code you have posted has nothign whatsoever to do with SQL, its merely assiging the values of the Session object to the variable $cart

    I suspect that what you actaully have is an SQL statement that is not terminated in php, so yyou have wrapped up the function declaration into a SQL statement, and not surprisiginly when you do execute the SQL statement its whinging about PHP inside SQL.



    I'd reccomend that durign development you make extensive use of the PHP "or die" function

    $ProductsListsr=@mysql_query($sql, $cnn) or die (echo ("LISTALLPRODUCTS", "<an error number>eg E:77654.1 - Failed to open rs:sqlr ".mysql_errno().": ".mysql_error()." <BR>The SQL was:".$sql));

    that helps for several reasons
    one you will know which SQL line threw the error if your error number is unique accross the project
    it will rpeort the MySQL error number and text formt he server
    but it will also show you what the SQL you actaully sent to the server was in the first place (assuming that $sql ios your SQL string, $cnn is the current valid connection)

    HTH

Posting Permissions

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