Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 2010
    Location
    L'Aquila
    Posts
    113
    Plugin Contributions
    1

    Default query mysql_escape_string

    Hi we use zen cart 155e, we have a file that uses this query $ sql [] = "LCASE (t1.products_name) LIKE '%". Mysqli_escape_string ($ v). "%'"; up to the php version 5.6 works perfectly, doing the update to version 7 of course does not work because mysql has been deprecated, how can you turn the query into mysqli? Thank you
    Erboristeria La Spiga e Il Girasole Herbal Shop - https://www.erboristeriabio.com
    Golden Eagle Herbal - https://www.erboristeriabio.it
    Giraspiga - https://www.giraspiga.com

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,492
    Plugin Contributions
    88

    Default Re: query mysql_escape_string

    You can use the Zen Cart function zen_db_prepare_input instead; it calls a database function which ultimately calls mysqli_escape_string, if that function is available.

  3. #3
    Join Date
    Jul 2010
    Location
    L'Aquila
    Posts
    113
    Plugin Contributions
    1

    Default Re: query mysql_escape_string

    Thanks I solved by doing this:

    $ con = @mysqli_connect (DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD);
    $ s [] = $ v;
    $ sql [] = "LCASE (t1.products_name) LIKE '%". mysqli_escape_string ($ con, $ v). "%'";

    regards
    Erboristeria La Spiga e Il Girasole Herbal Shop - https://www.erboristeriabio.com
    Golden Eagle Herbal - https://www.erboristeriabio.it
    Giraspiga - https://www.giraspiga.com

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,492
    Plugin Contributions
    88

    Default Re: query mysql_escape_string

    Save yourself a "world of hurt" and make use of the built-in Zen Cart $db object (and associated procedural functions) when accessing the Zen Cart database. Those classes and functions are there to insulate your code from underlying PHP changes (like the deprecation/removal of the mysql_* interfaces).

  5. #5
    Join Date
    Jul 2012
    Posts
    16,734
    Plugin Contributions
    17

    Default Re: query mysql_escape_string

    Quote Originally Posted by lat9 View Post
    You can use the Zen Cart function zen_db_prepare_input instead; it calls a database function which ultimately calls mysqli_escape_string, if that function is available.
    This may have been the case in the past; however, in ZC 1.5.5-1.5.5f the specific mysqli_ function is not invoked through zen_db_prepare_input on either the catalog or admin, it is accessible though through $db->prepare_input($stringText).

    Quote Originally Posted by lat9 View Post
    Save yourself a "world of hurt" and make use of the built-in Zen Cart $db object (and associated procedural functions) when accessing the Zen Cart database. Those classes and functions are there to insulate your code from underlying PHP changes (like the deprecation/removal of the mysql_* interfaces).
    HIGHLY AGREE that where it is possible to support/accomplish the desired/intended function that ZC code should be used to interface with ZC.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  6. #6
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,492
    Plugin Contributions
    88

    Default Re: query mysql_escape_string

    Quote Originally Posted by mc12345678 View Post
    This may have been the case in the past; however, in ZC 1.5.5-1.5.5f the specific mysqli_ function is not invoked through zen_db_prepare_input on either the catalog or admin, it is accessible though through $db->prepare_input($stringText).


    HIGHLY AGREE that where it is possible to support/accomplish the desired/intended function that ZC code should be used to interface with ZC.
    Thanks for the correction!

  7. #7
    Join Date
    Jul 2012
    Posts
    16,734
    Plugin Contributions
    17

    Default Re: query mysql_escape_string

    Quote Originally Posted by lat9 View Post
    Thanks for the correction!
    Forgot to add that I didn't review what *is* done through zen_db_prepare_input against the discussed mysqli_ function to see if the same operational result is obtained. Without that review it may (or not) do the same thing just through a different method.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  8. #8
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,492
    Plugin Contributions
    88

    Default Re: query mysql_escape_string

    I always get zen_db_prepare_input confused with zen_db_input; it's the latter procedural function that currently results in a call to mysqli_escape_string.

  9. #9
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,696
    Plugin Contributions
    123

    Default Re: query mysql_escape_string

    Quote Originally Posted by lat9 View Post
    I always get zen_db_prepare_input confused with zen_db_input; it's the latter procedural function that currently results in a call to mysqli_escape_string.
    This would be a great topic for the developer's notes.
    https://docs.zen-cart.com/Developer_Documentation/v2
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

 

 

Similar Threads

  1. Replies: 9
    Last Post: 12 Jul 2023, 12:26 AM
  2. v154 Help with a SQL Query for Query Builder
    By lindasdd in forum Managing Customers and Orders
    Replies: 2
    Last Post: 24 Mar 2016, 01:18 PM
  3. query
    By bebijuteria in forum General Questions
    Replies: 1
    Last Post: 10 Nov 2014, 08:30 PM
  4. v151 SQL query setup. How do I TEST a query 'off-line'?
    By lewisasding in forum General Questions
    Replies: 3
    Last Post: 8 Mar 2013, 12:24 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