Results 1 to 8 of 8
  1. #1
    Join Date
    May 2007
    Posts
    136
    Plugin Contributions
    0

    Default Warning: mysql_real_escape_string

    Hello Guys,

    I have a client that is getting the following error, I was thinking it was a miss configuration of the database link in the configure file, she informed me that the link is right and she is not using localhost.

    I’m open to any suggestions

    Code:
     
    Warning: mysql_real_escape_string(): Can't connect to MySQL server on 'localhost' (10061) in d:\inetpub\atomicaces\includes\classes\db\mysql\query_factory.php on line 56
     
    Warning: mysql_real_escape_string(): A link to the server could not be established in d:\inetpub\atomicaces\includes\classes\db\mysql\query_factory.php on line 56
     
    Warning: mysql_real_escape_string(): Can't connect to MySQL server on 'localhost' (10061) in d:\inetpub\atomicaces\includes\classes\db\mysql\query_factory.php on line 56
     
    Warning: mysql_real_escape_string(): A link to the server could not be established in d:\inetpub\atomicaces\includes\classes\db\mysql\query_factory.php on line 56
     
    Warning: mysql_real_escape_string(): Can't connect to MySQL server on 'localhost' (10061) in d:\inetpub\atomicaces\includes\classes\db\mysql\query_factory.php on line 56
     
    Warning: mysql_real_escape_string(): A link to the server could not be established in d:\inetpub\atomicaces\includes\classes\db\mysql\query_factory.php on line 56

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

    Default Re: Warning: mysql_real_escape_string

    Well, since the error message says 'localhost' but she's certain she's *not* using localhost, she needs to either check her facts, or get her hosting company involved to figure out what's wrong.

    Other things to consider:
    - when did this start happening?
    - when did it last work properly?
    - what version of Zen Cart?
    - what addons/contributions are installed?
    - what version of PHP?
    - what version of MySQL? Maybe there's a mismatch between client and server software?
    - where are these error messages appearing?
    - when do they occur?

    You'll probably have to log into her site yourself and inspect her configure.php files. Did she recently change something but forgot to change the configure.php files to writable before uploading changes, and then back to read-only again?

    The only reason there would be a call to 'localhost' from the query_factory script would be if something in the code is telling it to use localhost.
    Is there an addon that's not using the standard Zen Cart settings for accessing the database, perhaps accessing some special custom data?
    .

    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
    May 2007
    Posts
    136
    Plugin Contributions
    0

    Default Re: Warning: mysql_real_escape_string

    Thanks for the reply DrByte,

    What's happening is when she creates a profile she get this error after she hit submit.

    This is a new install (v1.3.7) she just set it up last week, the only mods she is using is a blog, cross sell items, and a category row/cell layout mod. Other than that it's a standard install.

    She also gets this error when she create a new profile, log-in, or tries to check out.

    ScreenShot
    http://test.c-s-wilson.com/log-in-error.bmp

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

    Default Re: Warning: mysql_real_escape_string

    What's the content of the /includes/configure.php file, without the database password?
    .

    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.

  5. #5
    Join Date
    May 2007
    Posts
    136
    Plugin Contributions
    0

    Default Re: Warning: mysql_real_escape_string

    Admin / Includes
    Code:
    <?php
    //
    /**
     *
     * @package Configuration Settings
     * @copyright Copyright 2003-2006 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     */
     
    /*************** NOTE: This file is similar, but DIFFERENT from the "store" version of configure.php. ***********/
    /***************       The 2 files should be kept separate and not used to overwrite each other.      ***********/
    // Define the webserver and path parameters
      // Main webserver: eg, http://localhost - should not be empty for productive servers
      // HTTP_SERVER is your Main webserver: eg, http://www.yourdomain.com
      // HTTPS_SERVER is your Secure webserver: eg, https://www.yourdomain.com
      // HTTP_CATALOG_SERVER is your Main webserver: eg, http://www.yourdomain.com
      // HTTPS_CATALOG_SERVER is your Secure webserver: eg, https://www.yourdomain.com
      /* 
       * URLs for your site will be built via:  
       *     HTTP_SERVER plus DIR_WS_ADMIN or
       *     HTTPS_SERVER plus DIR_WS_HTTPS_ADMIN or 
       *     HTTP_SERVER plus DIR_WS_CATALOG or 
       *     HTTPS_SERVER plus DIR_WS_HTTPS_CATALOG
       * ...depending on your system configuration settings
       */
      define('HTTP_SERVER', 'http://www.atomicaces.com');
      define('HTTPS_SERVER', 'https://www20.ssldomain.com/atomicaces');
      define('HTTP_CATALOG_SERVER', 'http://www.atomicaces.com');
      define('HTTPS_CATALOG_SERVER', 'https://www20.ssldomain.com/atomicaces');
      // Use secure webserver for catalog module and/or admin areas?
      define('ENABLE_SSL_CATALOG', 'false'); // true or false
      define('ENABLE_SSL_ADMIN', 'false'); // true or false
    // NOTE: be sure to leave the trailing '/' at the end of these lines if you make changes!
    // * DIR_WS_* = Webserver directories (virtual/URL)
      // these paths are relative to top of your webspace ... (ie: under the public_html or httpdocs folder)
      define('DIR_WS_ADMIN', '/admin/');
      define('DIR_WS_CATALOG', '/');
      define('DIR_WS_HTTPS_ADMIN', '/admin/');
      define('DIR_WS_HTTPS_CATALOG', '/');
      define('DIR_WS_IMAGES', 'images/');
      define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/');
      define('DIR_WS_CATALOG_IMAGES', HTTP_CATALOG_SERVER . DIR_WS_CATALOG . 'images/');
      define('DIR_WS_CATALOG_TEMPLATE', HTTP_CATALOG_SERVER . DIR_WS_CATALOG . 'includes/templates/');
      define('DIR_WS_INCLUDES', 'includes/');
      define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/');
      define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');
      define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');
      define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');
      define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');
      define('DIR_WS_CATALOG_LANGUAGES', HTTP_CATALOG_SERVER . DIR_WS_CATALOG . 'includes/languages/');
    // * DIR_FS_* = Filesystem directories (local/physical)
      //the following path is a COMPLETE path to your Zen Cart files. eg: /var/www/vhost/accountname/public_html/store/
      define('DIR_FS_ADMIN', 'd:/inetpub/atomicaces/admin/');
      define('DIR_FS_CATALOG', 'd:/inetpub/atomicaces/');
      define('DIR_FS_CATALOG_LANGUAGES', DIR_FS_CATALOG . 'includes/languages/');
      define('DIR_FS_CATALOG_IMAGES', DIR_FS_CATALOG . 'images/');
      define('DIR_FS_CATALOG_MODULES', DIR_FS_CATALOG . 'includes/modules/');
      define('DIR_FS_CATALOG_TEMPLATES', DIR_FS_CATALOG . 'includes/templates/');
      define('DIR_FS_BACKUP', DIR_FS_ADMIN . 'backups/');
      define('DIR_FS_EMAIL_TEMPLATES', DIR_FS_CATALOG . 'email/');
      define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
    // define our database connection
      define('DB_TYPE', 'mysql');
      define('DB_PREFIX', '');
      define('DB_SERVER', 'mysqla1.webcontrolcenter.com');
      define('DB_SERVER_USERNAME', 'XXXX');
      define('DB_SERVER_PASSWORD', 'XXXX');
      define('DB_DATABASE', 'atomicacesstore');
      define('USE_PCONNECT', 'false'); // use persistent connections?
      define('STORE_SESSIONS', 'db'); // use 'db' for best support, or '' for file-based storage
      // The next 2 "defines" are for SQL cache support.
      // For SQL_CACHE_METHOD, you can select from:  none, database, or file
      // If you choose "file", then you need to set the DIR_FS_SQL_CACHE to a directory where your apache 
      // or webserver user has write privileges (chmod 666 or 777). We recommend using the "cache" folder inside the Zen Cart folder
      // ie: /path/to/your/webspace/public_html/zen/cache   -- leave no trailing slash  
      define('SQL_CACHE_METHOD', 'none'); 
      define('DIR_FS_SQL_CACHE', 'd:/inetpub/atomicaces/cache');
    ?>
    Includes
    Code:
    <?php
    /**
     *
     * @package Configuration Settings
     * @copyright Copyright 2003-2006 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     */
     
    /*************** NOTE: This file is similar, but DIFFERENT from the "admin" version of configure.php. ***********/
    /***************       The 2 files should be kept separate and not used to overwrite each other.      ***********/
    // Define the webserver and path parameters
      // HTTP_SERVER is your Main webserver: eg, http://www.yourdomain.com
      // HTTPS_SERVER is your Secure webserver: eg, https://www.yourdomain.com
      define('HTTP_SERVER', 'http://www.atomicaces.com');
      define('HTTPS_SERVER', 'https://www20.ssldomain.com/atomicaces');
      // Use secure webserver for checkout procedure?
      define('ENABLE_SSL', 'false');
    // NOTE: be sure to leave the trailing '/' at the end of these lines if you make changes!
    // * DIR_WS_* = Webserver directories (virtual/URL)
      // these paths are relative to top of your webspace ... (ie: under the public_html or httpdocs folder)
      define('DIR_WS_CATALOG', '/');
      define('DIR_WS_HTTPS_CATALOG', '/');
      define('DIR_WS_IMAGES', 'images/');
      define('DIR_WS_INCLUDES', 'includes/');
      define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');
      define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');
      define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');
      define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');
      define('DIR_WS_DOWNLOAD_PUBLIC', DIR_WS_CATALOG . 'pub/');
      define('DIR_WS_TEMPLATES', DIR_WS_INCLUDES . 'templates/');
      define('DIR_WS_PHPBB', '/');
    // * DIR_FS_* = Filesystem directories (local/physical)
      //the following path is a COMPLETE path to your Zen Cart files. eg: /var/www/vhost/accountname/public_html/store/
      define('DIR_FS_CATALOG', 'd:/inetpub/atomicaces/');
      define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
      define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');
      define('DIR_WS_UPLOADS', DIR_WS_IMAGES . 'uploads/');
      define('DIR_FS_UPLOADS', DIR_FS_CATALOG . DIR_WS_UPLOADS);
      define('DIR_FS_EMAIL_TEMPLATES', DIR_FS_CATALOG . 'email/');
    // define our database connection
      define('DB_TYPE', 'mysql');
      define('DB_PREFIX', '');
      define('DB_SERVER', 'mysqla1.webcontrolcenter.com');
      define('DB_SERVER_USERNAME', 'XXXX');
      define('DB_SERVER_PASSWORD', 'XXXX');
      define('DB_DATABASE', 'atomicacesstore');
      define('USE_PCONNECT', 'false'); // use persistent connections?
      define('STORE_SESSIONS', 'db'); // use 'db' for best support, or '' for file-based storage
      // The next 2 "defines" are for SQL cache support.
      // For SQL_CACHE_METHOD, you can select from:  none, database, or file
      // If you choose "file", then you need to set the DIR_FS_SQL_CACHE to a directory where your apache 
      // or webserver user has write privileges (chmod 666 or 777). We recommend using the "cache" folder inside the Zen Cart folder
      // ie: /path/to/your/webspace/public_html/zen/cache   -- leave no trailing slash  
      define('SQL_CACHE_METHOD', 'none'); 
      define('DIR_FS_SQL_CACHE', 'd:/inetpub/atomicaces/cache');
    ?>

  6. #6
    Join Date
    Oct 2007
    Posts
    11
    Plugin Contributions
    0

    Default Re: Warning: mysql_real_escape_string

    Has there been any resolution to this problem as I am experiencing something very similar in relation to discount vouchers?

    http://www.zen-cart.com/forum/showthread.php?t=81493

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

    Default Re: Warning: mysql_real_escape_string

    Try editing your /includes/classes/db/mysql/query_factory.php file:
    around line 54 you'll see the following section of code:

    add the $this->link parameter as shown:
    Code:
      function prepare_input($zp_string) {
        if (function_exists('mysql_real_escape_string')) {
          return mysql_real_escape_string($zp_string, $this->link);
        } elseif (function_exists('mysql_escape_string')) {
          return mysql_escape_string($zp_string);
        } else {
          return addslashes($zp_string);
        }
      }
    .

    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.

  8. #8
    Join Date
    Oct 2007
    Posts
    11
    Plugin Contributions
    0

    Default Re: Warning: mysql_real_escape_string

    In the last couple of days I upgraded to 1.3.8 and this sorted out the problem I was experiencing, so I guess that may also be an option for anyone else having trouble pre-1.3.8.
    Something Sparkly - because life should sparkle
    www.somethingsparkly.co.uk

 

 

Similar Threads

  1. Replies: 1
    Last Post: 10 Oct 2014, 04:44 PM
  2. v151 final install page->mysql_real_escape_string() expects parameter 2 to be resource
    By torvista in forum Installing on a Linux/Unix Server
    Replies: 2
    Last Post: 3 Oct 2013, 09:31 AM
  3. v151 Protection from injection - mysql_real_escape_string
    By makenoiz in forum General Questions
    Replies: 12
    Last Post: 16 Aug 2013, 09:22 PM
  4. Replies: 1
    Last Post: 10 Dec 2010, 09:48 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