不确定我错过了什么,并且我在其他论坛或谷歌上找不到任何答案。 ._. 我应该在查询中添加什么?
$STH->bindParam(1, $name);
$STH->bindParam(2, $comment);
$STH = $db-("INSERT INTO comment ('name', 'comment') VALUES (:name, :comment)");
$STH->execute();
最佳答案
顺序应该是这样的:
$STH = $db->prepare("INSERT INTO comment ('name', 'comment') VALUES (:name, :comment)");
$STH->bindParam(':name', $name,PDO::PARAM_STR);
$STH->bindParam(':comment', $comment,PDO::PARAM_STR);
$STH->execute();
关于php - 非对象上的函数bindParam(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16350284/