"警告:mysqli_stmt :: bind_param():变量数量与预备语句中的参数数量不匹配" ...
我已经查看过有关此错误的许多问题,而且我无法理解我在哪里出错。我试图从数据库中获取一行并以现有形式显示记录,以便可以对其进行编辑和保存。我检查过SQL语句中有30个参数,$ stmt-> bind_param中有30个变量。有人可以指出我正确的方向,这是我的代码到目前为止:
// get the record from database - (30 parameters in mysql statement)
if ($stmt = $connect->prepare("SELECT id, start_date, company, stock_code, card_quantity, fiske_print, carrier_quantity, quoted, quote_details, quoted_date, quote_accepted, quote_accepted_date, proof_sent, proof_sent_date,proof_approved, proof_approved_date, printed, print_date, closed_loop_allocated, invoiced, invoiced_date, posted, tracking_number, postal_date, paid, is_bulk_load, bulk_funds_received, cards_loaded, notes, completed FROM jobs WHERE id = ?")) {
// 30 "s"'s - 30 $values
$stmt->bind_param("ssssssssssssssssssssssssssssss", $id,$start_date,$company,$stock_code,$card_quantity,$fiske_print,$carrier_quantity,$quoted,$quote_details,$quote_date,$quote_accepted,$quote_accepted_date,$proof_sent,$proof_sent_date,$proof_approved,$proof_approved_date,$printed,$printed_date,$closed_loop_allocated,$invoiced,$invoice_date,$posted,$tracking_number,$postal_date,$paid,$is_bulk_load,$bulk_funds_received,$cards_loaded,$notes,$completed);
$stmt->execute();
$stmt->bind_result($id,$start_date,$company,$stock_code,$card_quantity,$fiske_print,$carrier_quantity,$quoted,$quote_details,$quote_date,$quote_accepted,$quote_accepted_date,$proof_sent,$proof_sent_date,$proof_approved,$proof_approved_date,$printed,$printed_date,$closed_loop_allocated,$invoiced,$invoice_date,$posted,$tracking_number,$postal_date,$paid,$is_bulk_load,$bulk_funds_received,$cards_loaded,$notes,$completed);
$stmt->fetch();
// show the form
renderForm(NULL, $id,$start_date,$company,$stock_code,$card_quantity,$fiske_print,$carrier_quantity,$quoted,$quote_details,$quote_date,$quote_accepted,$quote_accepted_date,$proof_sent,$proof_sent_date,$proof_approved,$proof_approved_date,$printed,$printed_date,$closed_loop_allocated,$invoiced,$invoice_date,$posted,$tracking_number,$postal_date,$paid,$is_bulk_load,$bulk_funds_received,$cards_loaded,$notes,$completed);
echo 'We are about to edit an existing job ' . $id;
$stmt->close();
}
答案 0 :(得分:0)
您需要绑定的唯一参数是您搜索的ID而不是您选择的字段
if ($stmt = $connect->prepare("SELECT id, start_date, company, stock_code, card_quantity, fiske_print, carrier_quantity, quoted, quote_details, quoted_date, quote_accepted, quote_accepted_date, proof_sent, proof_sent_date,proof_approved, proof_approved_date, printed, print_date, closed_loop_allocated, invoiced, invoiced_date, posted, tracking_number, postal_date, paid, is_bulk_load, bulk_funds_received, cards_loaded, notes, completed FROM jobs WHERE id = ?")) {
$stmt->bind_param("i", $id);
$stmt->execute();