0
所以我希望得到一個帖子的ID,其中標題=‘$ someTitle’PDO讀取行以」
$dbh= new PDO("mysql:host=localhost;dbname=NAME",'USER','PASS',
array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
));
$someTitle = '\"If you\'re absent during my struggle, don\'t expect to be present during my success.\" - Will Smith';
$statement = $dbh->prepare("select id from posts where title = :title");
$statement->execute(array(':title' => $someTitle));
$row = $statement->fetch();
echo $row[id];
而這個例子dosent工作,但如果我$ someTitle更改爲$ someTitle ='新的測試';
每一件事情是確定的
任何提示
是的,解決它。謝謝Marc! – Ben 2012-02-13 05:23:46