我正在努力为我的项目找到错误的解决方案,有人可以帮助我并告诉我正确的方法吗。
这是我的代码:
$productkey = $_SESSION['key'];
$productuser = $_SESSION['user'];
$productemail = $_SESSION['email'];
// Include Database Connection
require 'assets/sys/config.php';
$query = dbConnect()->prepare("INSERT INTO _system (_product_key, _product_user, _product_email, _site_email, _site_title) VALUES (:_product_key, :_product_user, :_product_email, :_site_title, :site_email)");
$query->bindParam(':_product_key', $productkey);
$query->bindParam(':_product_user', $productuser);
$query->bindParam(':_product_email', $productemail);
$query->bindParam(':_site_title', $_POST['sitetitle']);
$query->bindParam(':_site_email', $_POST['siteemail']);
$query->execute();
我收到的错误:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: parameter was not defined' in
最佳答案
在您的查询中您有:
:site_email
但是你确实绑定(bind)了这个:
$query->bindParam(':_site_email', $_POST['siteemail']);
那些是不同的,编辑:
$query->bindParam(':site_email', $_POST['siteemail']);
或者改变你的sql参数。
关于php - 'PDOException' 消息 'SQLSTATE[HY093] : Invalid parameter number:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27479778/