Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2008
    Posts
    71
    Plugin Contributions
    0

    Default php script error question

    I'm getting this error once the script is triggered:

    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 'where customers_id = '6 set customers_group_pricing = '4'' at line 1
    in:
    [update zen_cartcustomers where customers_id = '6 set customers_group_pricing = '4']

    when I try to apply this code:

    global $db;
    if (!$_SESSION['cart']->in_cart('products_id', '121')) {
    $db->Execute("update " . TABLE_CUSTOMERS ." where customers_id = '" . (int)$_SESSION['customer_id'] . " set customers_group_pricing = '4'");
    }

    So I know I am off in my scripting a little somewhere. No error log debug. So I am hoping someone can see where I scripted wrong. I am trying to write the customers (customer id is 6 in this case) group pricing field in the database when this product 121 is in the cart. It look like it is having a problem with the numbers, either customers id or ??? I'm thinking a space/period/quote somewhere will bring it all together, but I don't know... any body see my typo/script mistake?

  2. #2
    Join Date
    Jan 2010
    Location
    Australia
    Posts
    239
    Plugin Contributions
    1

    Default Re: php script error question

    you are missing ' after 6 it should be


    ...
    ...
    $db->Execute("update " . TABLE_CUSTOMERS ." where customers_id = '" . (int)$_SESSION['customer_id'] . '" set customers_group_pricing = '4'");
    }
    Believe it or not But My existence is illusional

  3. #3
    Join Date
    Nov 2008
    Posts
    71
    Plugin Contributions
    0

    Default Re: php script error question

    Okay so now I've got that ' straight and I'm still getting:
    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 'where customers_id = '7' set customers_group_pricing = '4'' at line 1
    in:
    [update zen_cartcustomers where customers_id = '7' set customers_group_pricing = '4']

    from=
    global $db;
    if (!$_SESSION['cart']->in_cart('products_id', '121')) {
    $db->Execute("update " . TABLE_CUSTOMERS ." where customers_id = '" . (int)$_SESSION['customer_id'] . "' set customers_group_pricing = '4'");
    }

    so am I getting the = '4' wrong? == 4 , or some other variation to get the code to write it to the db field correctly? It says the syntax is wrong, which makes me think that I'm messing up the code to get it into the database.... ??

  4. #4
    Join Date
    Nov 2008
    Posts
    71
    Plugin Contributions
    0

    Default Re: php script error question

    I'm looking at an " or' in the wrong place.....

    "update " . TABLE_CUSTOMERS ." where customers_id = '" . (int)$_SESSION['customer_id'] . "' set customers_group_pricing = '4'"


    unfortunately I can see that there is a bad order for them but can't figure out the right one to move/delete/edit... and have tried a bunch of different ways, it just takes forever to run a test so I'm hoping someone who knows this better than me can easily look at it and see how I am making the dumb mistake I know I'm making :) Thanks!
    Last edited by danwebman; 16 Dec 2011 at 02:02 PM.

  5. #5
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: php script error question

    Your IF is incorrect ...

    You need to use:
    Code:
    if (!$_SESSION['cart']->in_cart(121)) {
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  6. #6
    Join Date
    Nov 2008
    Posts
    71
    Plugin Contributions
    0

    Default Re: php script error question

    Hi Linda, Thanks! I have made the adjustment but am still getting an error. Do I need to apply the (4) to the #'s in the bottom line of the code ? I've tried = 4 , = '4', or can you see another eror that I'm doing? I could really use some help here. I'm stuck on one line to finish the entire cart. Very frustrated

    if (!$_SESSION['cart']->in_cart(121)) {
    $db->Execute("update " . TABLE_CUSTOMERS ." where customers_id = " . (int)$_SESSION['customer_id'] . " set customers_group_pricing = 4");
    }

  7. #7
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: php script error question

    Like duh ... this took me long enough to notice ...

    You have the syntax wrong ... you need the SET before the WHERE ...
    Code:
    $db->Execute("update " . TABLE_CUSTOMERS . " set customers_group_pricing = 4" . " where customers_id = " . (int)$_SESSION['customer_id'] . "");
    NOTE: before you use this code ... where are you using this code?
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

 

 

Similar Threads

  1. v154 application/x-httpd-php html_header.php PHP script text
    By Parafanaylya in forum General Questions
    Replies: 3
    Last Post: 29 Aug 2015, 03:06 PM
  2. Sidebox & PHP Script question
    By Webgremlin in forum Basic Configuration
    Replies: 0
    Last Post: 3 Feb 2010, 02:44 AM
  3. Premature end of script headers: php-script
    By doubletiger in forum General Questions
    Replies: 8
    Last Post: 2 Jul 2006, 09:53 PM

Posting Permissions

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