SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: PDO Quote

  1. #1
    John 8:24 JREAM's Avatar
    Join Date
    Sep 2007
    Location
    Florida
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PDO Quote

    Heya,

    I spent an hour trying to get this right and reading documentation but can't seem to get it right. I can't get the strings to "escape", I'm not sure how to issue the quote() statement.

    PHP Code:
    $this->DB = new PDO("mysql:host=$DB_HOST;dbname=$DB_NAME"$DB_USER$DB_PASS);

    //
    // How do I get this to escape string?
    $this->DB->quote($strData);

    $this->STMT $this->DB->prepare($strData);
    $this->STMT->execute(); 

    [06-27-2010 12:19pm] 42000 | 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 'a w'ebsite abut something',`listing_id` = '8' WHERE listing_id = '8'' at line 2



    It appears that PDO has a Base Class and a Statement class. To use the PDOStatements It seems that the PDO Base class has some sort of __toString() method which passes me over to PDOStatement.

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    You don't need to escape data with PDO prepared statements...
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    John 8:24 JREAM's Avatar
    Join Date
    Sep 2007
    Location
    Florida
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh I see, lol.

    I think it's because I'm not supposed to use a prepared statement for what Im doing, thank you sir this fixes my trubles lol.


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
  •