如何在使用PDO時無法使mysql_real_escape_string
正常工作?我一直在使用在調用mysql_real_escape_string()時出現「拒絕訪問」錯誤的故障
try {
include "connect_to_db.php";
$sql = sprintf("NULL, '%s'",
mysql_real_escape_string('Woot')
);
$count = $dbh->exec($sql);
$dbh = null;
}
catch(PDOException $e){
echo $e->getMessage();
}
錯誤總是指向行,其中mysql_real_escape_string是
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in D:\pathhere\file.php on line 44
我甚至使用root用戶現在進行測試,但它仍然無法工作時收到錯誤。
可能的重複:http://stackoverflow.com/questions/6384423/mysql-real-escape-string-doesnt-work –
如果您可以在這裏插入錯誤消息/代碼,這將是更容易建議的解決方案。 – farzad