Results 1 to 6 of 6
  1. #1
    Join Date
    May 2005
    Location
    Cheshire, UK
    Posts
    542
    Plugin Contributions
    3

    Default How Will Removing the \ affect functionality?

    I am still working on an MS Access offline database system for Zencart and I am currently building the Installer into MS Access. There are one or two issues which MS Access does not like and I need to know if I can change then without introducing bugs.

    For this example I need to know if removing \ from an Insert statement will affect functionality.

    MySQL CODE:
    INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Expected Sort Order', 'EXPECTED_PRODUCTS_SORT', 'desc', 'This is the sort order used in the expected products box.', '1', '8', 'zen_cfg_select_option(array(\'asc\', \'desc\'), ', now());

    Once converted to Acess this becomes:
    VBA CODE:
    CurrentDb.Execute "INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Expected Sort Order', 'EXPECTED_PRODUCTS_SORT', 'desc', 'This is the sort order used in the expected products box.', '1', '8', 'zen_cfg_select_option(array(\'asc\', \'desc\'), ', now());"

    Access has a problem with this bit:
    CODE:
    (array(\'asc\', \'desc\'), ', now());

    In particular Access dislikes the \ because it expects a command. What is the purpose of the \ in the statement for zencart and can it be safely removed?

    If not I will need to find some way of escaping the \ so Access does not complain.

    Thanks for any insights

    Jim

  2. #2
    Join Date
    Nov 2007
    Location
    Melbourne, Australia
    Posts
    541
    Plugin Contributions
    0

    Default Re: How Will Removing the \ affect functionality?

    The backslash it required in PHP to escape the ' character. When you want to execute the MYSQL statement in PHP, ' is used to limit a string. And the MySQL command is a string too. When you use Access, you probably dont need to escape the ' character thus you can remove the \ (backslash).

    Hope that makes is clear :)

  3. #3
    Join Date
    May 2005
    Location
    Cheshire, UK
    Posts
    542
    Plugin Contributions
    3

    Default Re: How Will Removing the \ affect functionality?

    Quote Originally Posted by tino.schlegel View Post
    The backslash it required in PHP to escape the ' character. When you want to execute the MYSQL statement in PHP, ' is used to limit a string. And the MySQL command is a string too. When you use Access, you probably dont need to escape the ' character thus you can remove the \ (backslash).

    Hope that makes is clear :)
    Thanks Tino - pretty much what I thought but you have kindly confirmed it form me. It looks like removing the backslash will be safe for Access without introducing bugs into Zencart.

    Many thanks

    Jim

  4. #4
    Join Date
    May 2005
    Location
    Cheshire, UK
    Posts
    542
    Plugin Contributions
    3

    Default Re: How Will Removing the \ affect functionality?

    hmm - removing the backslash causes MS Access to throw a new error: Warning - Missing Operator

    CurrentDb.Execute "INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Expected Sort Order', 'EXPECTED_PRODUCTS_SORT', 'desc', 'This is the sort order used in the expected products box.', '1', '8', 'zen_cfg_select_option(array('asc', 'desc'), ', now());"

    The only difference is the removal of the backslash. This code should in fact be valid. It certainly relates to this portion of the code:
    'zen_cfg_select_option(array('asc', 'desc'), ', now());"

    I tried replacing (array('asc', 'desc'), ', now());"

    with

    (array('asc', 'desc'), '', now());"

    But this did not work.

    Any ideas anyone?

  5. #5
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: How Will Removing the \ affect functionality?

    Without the backslashes escaping the apostrophes, you end up with mismatched quotes, which is what is causing your error message.

    Look at it strictly from the apostrophes:
    'zen_cfg_select_option(array('asc', 'desc'), ', now());"
    becomes:
    'zen_cfg_select_option(array('
    AND another string immediately following it, without a comma:
    asc', 'desc'), ', now());"
    Of course, that string also has quotes and commas in it, which make no sense unless the quotes are escaped as well.

    The quotes need escaping or they can't be nested as required.

    Perhaps you've discovered another MS deficiency?
    .

    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.

  6. #6
    Join Date
    May 2005
    Location
    Cheshire, UK
    Posts
    542
    Plugin Contributions
    3

    Default Re: How Will Removing the \ affect functionality?

    Quote Originally Posted by DrByte View Post
    Without the backslashes escaping the apostrophes, you end up with mismatched quotes, which is what is causing your error message.

    Look at it strictly from the apostrophes:
    'zen_cfg_select_option(array('asc', 'desc'), ', now());"
    becomes:
    'zen_cfg_select_option(array('
    AND another string immediately following it, without a comma:
    asc', 'desc'), ', now());"
    Of course, that string also has quotes and commas in it, which make no sense unless the quotes are escaped as well.

    The quotes need escaping or they can't be nested as required.

    Perhaps you've discovered another MS deficiency?
    Thanks for the input Dr B. I had a rethink about this based on what you said here and found a very simple compromise. Since it was the backslashes causing the error in MS Access but the backslashes are needed to escape the quotes, it became clear to me MS Access disliked the backslashes for escaping the quotes and would prefer something else. So I dug a little deeper and the solution is to replace the backslashes with and apostophe ' because this is how MS Access escapes the quotes.

    This seems a fair compromise which does the same job without rewriting the code. It just means I will need to spend a lot of time debugging the MS Access code line by line until all backslashes used to escape quotes have been replaced with the MS Access equivalent.

    Thanks again - one step closer today to the offline database management system being completed :)

    Jim

 

 

Similar Threads

  1. Will Disabling Gift Certificates Affect My Current Customers?
    By Jac Web in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 7
    Last Post: 14 Nov 2015, 12:24 AM
  2. Paypal how will this affect us (answer: it doesn't)
    By scooby3134 in forum Addon Payment Modules
    Replies: 2
    Last Post: 16 Mar 2014, 01:57 PM
  3. v150 Will changing attributes on a product affect prior purchases?
    By treblesand in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 25 Apr 2013, 01:44 PM
  4. How will changing these dates affect functionality?
    By JollyJim in forum General Questions
    Replies: 2
    Last Post: 24 Nov 2009, 12:17 AM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR