【发布时间】:2016-02-06 00:32:15
【问题描述】:
我正在学习 php 并尝试完成以下工作:
<?php
require_once("db_connect.php");
// TODO - Check that connection was successful.
$dname = $_POST["dname"];
$daddress = $_POST["daddress"];
$stmt = $mysqli->prepare("INSERT INTO test (dname, daddress) VALUES (?, ?)");
// TODO check that $stmt creation succeeded
// "s" means the database expects a string
$stmt->bind_param("s", $dname, $daddress);
$stmt->execute();
$stmt->close();
$mysqli->close();
?>
它只适用于一个 bind_param 而不是 2。如果 $daddress 从代码中删除,则它会发布。该表单有 26 个帖子到数据库中,我目前正在使用 2 个帖子来保持它的最小化。
提交表单时出现以下错误。
警告:mysqli_stmt::bind_param() [mysqli-stmt.bind-param]:类型定义字符串中的元素数与 /home/mymotorsportco/public_html/entry/actions/entry 中的绑定变量数不匹配。第15行的php
【问题讨论】: