Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2004
    Posts
    38
    Plugin Contributions
    0

    Default error updating field in custom table

    i'm working on a way to update some data in a custom table that updates when the cart triggers session_recreate_id

    1. i've added the table name customer2_data to database_tables.php (TABLE_CUSTOMER2_DATA)

    2. inserted the function name in sessions.php to trigger just before the whos_online_session_recreate($oldSessID, $newSessID);

    customerIPfield_session_recreate($oldSessID, $newSessID);
    whos_online_session_recreate($oldSessID, $newSessID);

    3. added an extra_function that sorta parallels the whos_online_session_recreate function but first checks for the customer's IP, if it finds the customer's IP in the customer2_data customerIP field, then it should update the session id in that table row too:
    PHP Code:
    function customerIPfield_session_recreate($old_session$new_session) {
      global 
    $db;
      
    $customer_ip_current $_SERVER['REMOTE_ADDR'];

    $sql "select customerIP from " TABLE_CUSTOMER2_DATA " where customerIP = :customer_ip_current";
    $sql $db->bindVars($sql':customer_ip_current'$customer_ip_current'noquotestring');
    $result $db->Execute($sql);

    if (
    $result->RecordCount() > 0) {

      
    $sql "UPDATE " TABLE_CUSTOMER2_DATA "
              SET session_id = :newSessionID 
              WHERE session_id = :oldSessionID
              AND customerIP = :customer_ip_current"
    ;
              
      
    $sql $db->bindVars($sql':newSessionID'$new_session'string'); 
      
    $sql $db->bindVars($sql':oldSessionID'$old_session'string'); 
      
    $sql $db->bindVars($sql':customer_ip_current'$customer_ip_current'noquotestring'); 
      
    $db->Execute($sql);
      
    } else {

    //
    //  
    }
       

    However, when I add something to the cart and then try to login (triggering session recreate), I get the following error:

    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 '.56.789' at line 1
    in:
    [select customerIP from customer2_data where customerIP = 123.34.56.789]

    any idea what be the issue? i've tweaked a few things but keep getting the same error

    thanks
    Last edited by boxes; 3 Oct 2012 at 07:40 PM.
    peace

  2. #2
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: updating field in custom table after session recreate

    Simple. 123.34.56.789 is being treated as a number because you didn't surround it with 'quote' marks. Thus it's failing after it accepts the number of 123.34 and dies at the second decimal point because no "number" contains two decimal points.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Jul 2004
    Posts
    38
    Plugin Contributions
    0

    Default Re: updating field in custom table after session recreate

    thanks so much Dr, on the money
    peace

 

 

Similar Threads

  1. v154 Issue with Authorize.net AIM updating table - error 1366 incorrect integer value
    By inklingsolutions in forum Built-in Shipping and Payment Modules
    Replies: 48
    Last Post: 29 Dec 2016, 09:09 PM
  2. v151 Adding a Custom field to the products table
    By jimmie in forum General Questions
    Replies: 4
    Last Post: 17 Sep 2013, 11:14 PM
  3. v139h Search on custom products table flag field p.products_gift=1
    By makenoiz in forum General Questions
    Replies: 2
    Last Post: 5 Aug 2012, 10:08 PM
  4. Help with error when inserting/updating custom product
    By cliftonj in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 26 Apr 2012, 01:57 PM
  5. Adding Custom Field to Customer Table
    By experimenter in forum General Questions
    Replies: 3
    Last Post: 26 Sep 2008, 08:36 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