$dml = "insert into bookmark(accountId,category,url,hash,title,created) value($_SESSION[accountId],$_POST[category],'$_POST[url]',md5('$_POST[url]'),'$_POST[title]',now())";
mysql_query($dml,$con);
如何在 PDO 中使用准备好的语句来执行此语句?
最佳答案
$dml = "INSERT INTO bookmark (accountId, category, url, hash, title, created) " . "VALUES (:accountId, :category, :url, MD5(:url), :title, NOW())"; $statement = $pdo->prepare($dml); $parameters = array( ":accountId" => $_SESSION["accountId"], ":category" => $_POST["category"], ":url" => $_POST["url"], ":title" => $_POST["title"]); $statement->execute($parameters);
关于php - 如何使用 PHP 中的准备语句从 mysql 更改为 pdo?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2211919/