// if the 'id' variable is not set in the URL, we must be creating a new record
else
{
// if the form's submit button is clicked, we need to process the form
if (isset($_POST['submit']))
{
// get the form data
$mtcn = htmlentities($_POST['mtcn'], ENT_QUOTES);
$amount = htmlentities($_POST['amount'], ENT_QUOTES);
$currency = htmlentities($_POST['currency'], ENT_QUOTES);
$sender_name = htmlentities($_POST['sender_name'], ENT_QUOTES);
$sender_country = htmlentities($_POST['sender_country'], ENT_QUOTES);
$receiver_name = htmlentities($_POST['receiver_name'], ENT_QUOTES);
$comment = htmlentities($_POST['comment'], ENT_QUOTES);
$support = htmlentities($_POST['support'], ENT_QUOTES);
$email = htmlentities($_POST['email'], ENT_QUOTES);
// check that mtcn and amount are both not empty
if ($mtcn == '' || $amount == '')
{
// if they are empty, show an error message and display the form
$error = 'ERROR: Please fill in all required fields!';
renderForm($mtcn, $amount, $currency, $sender_name, $sender_country, $receiver_name, $comment, $support, $email, $error);
}
else
{
// insert the new record into the database
if ($stmt = $mysqli->prepare("INSERT date (mtcn, amount, currency, sender_name, sender_country, receiver_name, comment, support, email) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"))
{
$stmt->bind_param("ss", $mtcn, $amount, $currency, $sender_name, $sender_country, $receiver_name, $comment, $support, $email);
$stmt->execute();
$stmt->close();
}
// show an error if the query has an error
else
{
echo "ERROR: Could not prepare SQL statement.";
}
// redirec the user
// header("Location: view.php");
}
}
// if the form hasn't been submitted yet, show the form
else
{
renderForm();
}
}
// close the mysqli connection
$mysqli->close();
当我运行脚本时,我收到错误:
Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of elements in type definition string doesn't match number of bind variables in C:\wamp\www\records.php on line 205 Warning: mysqli_stmt::execute() [mysqli-stmt.execute]: (HY000/2031): No data supplied for parameters in prepared statement in C:\wamp\www\records.php on line 206
知道如何解决它吗?我计算了bind_param中的参数,它们对我来说似乎很好……
解决方法:
我觉得你需要更多的东西吗?
$stmt->bind_param("ss", $mtcn, $amount, $currency, $sender_name, $sender_country, $receiver_name, $comment, $support, $email);
试试这个(假设它们都是字符串)
$stmt->bind_param("sssssssss", $mtcn, $amount, $currency, $sender_name, $sender_country, $receiver_name, $comment, $support, $email);
标签:php,mysql,ssd 来源: https://codeday.me/bug/20190925/1817026.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。