Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13
  1. #11
    Join Date
    Mar 2006
    Posts
    283
    Plugin Contributions
    0

    Default Re: Protection from injection - mysql_real_escape_string

    Thanks for that... date coming in as 0000-00-00 00:00:00 but at least its writing to the table. Ill work on it a bit and report the fix if I find.

    Thanks
    22 stores and counting! Ive been zenned.

  2. #12
    Join Date
    Mar 2006
    Posts
    283
    Plugin Contributions
    0

    Default Re: Protection from injection - mysql_real_escape_string

    Should I sanatize SELECT and DELETE statements as well using bindVars and placeholders?

    Also the problem that I was having above was that the now() should not have been in the bindVars statements but rather in the placeholders statements.

    This is what is working now:

    Code:
    $sql = "INSERT INTO " . TABLE_ACME_PRODS . " (`acme_products_id`,`acme_products_partno`, `acme_products_orderno`, `acme_manus_id`, `acme_model_id`, `acme_products_years`, `acme_products_type`, `acme_products_catid`, `acme_products_catname`, `acme_products_matid`, `acme_products_matname`, `acme_products_dateAdded`)
                VALUES (:products_id, :products_partno, :products_orderno, :products_manuid, :products_modelid, :products_years, :products_typeid, :products_catid, :products_typename, :products_matid, :products_matname, now())";
                    $sql = $db->bindVars($sql, ':products_id', $buildacmeProductID, 'string');
                    $sql = $db->bindVars($sql, ':products_partno',$resultProduct->attributes()->partNo, 'string');
                    $sql = $db->bindVars($sql, ':products_orderno',$resultProduct->attributes()->orderNo, 'string');
                    $sql = $db->bindVars($sql, ':products_manuid',$resultProduct->Manufacturer->attributes()->id, 'string');
                    $sql = $db->bindVars($sql, ':products_modelid',$resultProduct->Model->attributes()->id, 'string');
                    $sql = $db->bindVars($sql, ':products_years',$resultProduct->Years, 'string');
                    $sql = $db->bindVars($sql, ':products_typeid',$resultProduct->ProductType->attributes()->id, 'string');
                    $sql = $db->bindVars($sql, ':products_catid',$resultProduct->ProductType->attributes()->categoryID, 'string');
                    $sql = $db->bindVars($sql, ':products_typename',$resultProduct->ProductType, 'string');
                    $sql = $db->bindVars($sql, ':products_matid',$resultProduct->Material->attributes()->id, 'string');
                    $sql = $db->bindVars($sql, ':products_matname',$resultProduct->Material, 'string');
                     
                     echo "<BR />DEBUG 10 SQL statement = ".$sql;
                    
                    $db->Execute($sql);
    Quote Originally Posted by DrByte View Post
    You can use now() but you must place it inside quotes: 'now()'
    22 stores and counting! Ive been zenned.

  3. #13
    Join Date
    Jan 2004
    Posts
    66,387
    Blog Entries
    7
    Plugin Contributions
    81

    Default Re: Protection from injection - mysql_real_escape_string

    Quote Originally Posted by makenoiz View Post
    Also the problem that I was having above was that the now() should not have been in the bindVars statements but rather in the placeholders statements.
    That shouldn't be necessary. But since there's no sanitizing required, what you've changed it to is fine.

    Quote Originally Posted by makenoiz View Post
    Should I sanatize SELECT and DELETE statements as well using bindVars and placeholders?
    Yes. Always.
    .

    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.

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Security Alert: SQL Injection Protection 2008-09-19
    By DrByte in forum Zen Cart Release Announcements
    Replies: 2
    Last Post: 30 Sep 2008, 06:21 AM
  2. Replies: 1
    Last Post: 29 Sep 2008, 05:55 PM

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