Escapeing values in PDO statements

Posted by Pardoner on Stack Overflow See other posts from Stack Overflow or by Pardoner
Published on 2011-01-04T23:44:51Z Indexed on 2011/01/04 23:53 UTC
Read the original article Hit count: 172

Filed under:
|
|

Doesn't prepare() escape any quotes(') in a PDO statement? For some reason when I do this:

$sql = "INSERT INTO sessions (id, name) VALUES (1,'O'brian')";
$query = $this->connection->prepare($sql);
$query->execute();

I get this error:

Could not insert record SQLSTATE[42000]: [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near 'brian'.

How could this be if I'm using prepare()?

© Stack Overflow or respective owner

Related posts about php

Related posts about pdo