我正在尝试使用PHP PDO运行此SQL查询:
$stmt = $pdo_conn->prepare("select * from billing_pdf_archive where invoice_number = :invoice_number and sequence = :sequence ");
$stmt->execute(array(
':invoicenumber' => $_GET["inv"],
':sequence' => $_GET["seq"]
)
);
$result = $stmt->fetch();
注意:$_GET["inv"]
和$_GET["seq"]
在回显时显示数据
但我收到此错误
致命错误:未捕获异常'PDOException',消息'SQLSTATE [HY093]:参数号无效:参数未定义'/home/integra/public_html/lifeline/billing/resendpdfinvoice.php:94堆栈跟踪:#0 /home/integra/public_html/lifeline/billing/resendpdfinvoice.php(94):第94行/home/integra/public_html/lifeline/billing/resendpdfinvoice.php中抛出PDOS方法 - >执行(数组)#1 {main}
我无法弄清楚它有什么问题
答案 0 :(得分:3)
where invoice_number = :invoice_number
^---- underscore here
$stmt->execute(array(':invoicenumber' => $_GET["inv"],
^---no underscore here
答案 1 :(得分:2)
见这里
invoicenumber!=invoice_number
答案 2 :(得分:2)
当您的执行语句要求:invoice_number
时,您的查询似乎包含:invoicenumber
。尝试将它们设置为相同的值(例如:invoice_number
)
$stmt = $pdo_conn->prepare("select * from billing_pdf_archive"
. " where invoice_number = :invoice_number and sequence = :sequence ");
$stmt->execute(array(
':invoice_number' => $_GET["inv"],
':sequence' => $_GET["seq"]
));
$result = $stmt->fetch();