$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);
How do I do this statement using prepared statements in PDO?
$dml = $db->prepare("INSERT INTO bookmark (accountId, category, url, hash, title, created) VALUES (:account_id, :category, :url, MD5(:url), :title, NOW());");
$dml->bindParam(':account_id', $_SESSION['accountId']);
$dml->bindParam(':category', $_POST['category']);
$dml->bindParam(':url', $_POST['url']);
$dml->bindParam(':title', $_POST['title']);
$dml->execute();
$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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.