警告:mysqli_stmt :: bind_param():类型定义字符串中的元素数量与绑定变量的数量不匹配
stmt->bind_param("ssssssssssss",
_POST[‘id’], _POST['start_date'],_POST[‘end_date’],_POST['cars'],
_POST[‘Location_of_renting’],_POST['Location_of_returning'],
_POST[‘vr_uzi’], _POST['vr_vraca'], _POST[‘paid’], _POST['price'],
_POST[‘numberdays’], $_POST[‘Numbers_of_cars’]);
任何人都看到变量数与准备好的语句中的参数数不匹配
答案 0 :(得分:0)
<form action="" name="form" class="form-horizontal" style="width: 95%; margin:0 2.5% 2.5%" method="POST">
<div class="control-group">
<label class="control-label" for="checkInDate">Start date:</label>
<div class="controls">
<input class="sa" type="text" id="dpd1" name="start_date" value='' size="16" readonly width="150px" data-date-format="yyyy-mm-dd">
</div>
</div>
<div class="control-group">
<label class="control-label" for="End date">End date :</label>
<div class="controls">
<input class="sa" type="text" readonly size="16" id="dpd2" name="end_date" value='' data-date-format="yyyy-mm-dd">
</div>
</div>
<div class="control-group">
<label class="control-label" for="cars">Kind of car:</label>
<div class="controls"><select class="s" id="cars" name="cars">
<option value="Select">Select</option>
<option value="1 ">Skoda manual gas</option>
<option value="2">Passat</option>
<option value="3">Kia</option>
<option value="4">Volvo</option>
<option value="5 ">Skoda automatic disel</option>
</select></div>
</div>
<div class="control-group">
<label class="control-label" for="Location_of_renting">Location of renting:</label>
<div class="controls">
<select class="input-medium" id="Location_of_renting" name="Location_of_renting">
<option value="Select">Select</option>
<option value="Santa Barbara">Santa Barbara</option>
<option value="Los Angeles">Los Angeles</option>
<option value="San Diego">San Diego</option>
</select>
<select class="input-medium" id="vr_uzi" name="vr_uzi">
<option value="8:00">8:00</option>
<option value="9:00 ">9:00 </option>
<option value="10:00">10:00</option>
<option value="11:00">11:00</option>
<option value="12:00">12:00</option>
<option value="13:00 ">13:00 </option>
<option value="13:00">13:00</option>
<option value="14:00">14:00</option>
<option value="15:00">15:00</option>
<option value="16:00 ">16:00 </option>
<option value="17:00">17:00</option>
<option value="18:00">18:00</option>
</select>
</div></div>
<div class="control-group">
<label class="control-label" for="Location_of_returning">Location of returning:</label>
<div class="controls">
<select class="input-medium" id="Location_of_returning" name="Location_of_returning">
<option value="Select">Select</option>
<option value="Santa Barbara">Santa Barbara</option>
<option value="Los Angeles">Los Angeles</option>
<option value="San Diego">San Diego</option>
</select>
<select class="input-medium" id="vr_vraca" name="vr_vraca">
<option value="8:00">8:00</option>
<option value="9:00 ">9:00 </option>
<option value="10:00">10:00</option>
<option value="11:00">11:00</option>
<option value="12:00">12:00</option>
<option value="13:00 ">13:00 </option>
<option value="13:00">13:00</option>
<option value="14:00">14:00</option>
<option value="15:00">15:00</option>
<option value="16:00 ">16:00 </option>
<option value="17:00">17:00</option>
<option value="18:00">18:00</option>
</select>
</div></div>
<button id="submit" name="submit" action="http://localhost/carbooking3/16%20y/korak22.php?id=" class="sear-btn" type="submit">Search</button>
<div align="right">
<input type="hidden" name="MM_insert" value="form">
</form>
<?php
if (isset($_POST['submit'])) {
$conn= mysqli_connect('127.0.0.1', 'root', '');
if(!$conn) {
die('Could not connect: ' . mysqli_error());
} else {
echo 'ooooooooooooo111';
}
$conn->select_db('cars123');
// prepare and bind
/*<?php ?> $start_date=$_POST['start_date'];
$end_date=$_POST['end_date'];
$cars=$_POST['cars'];
$Location_of_renting=$_POST['Location_of_renting'];
$Location_of_returning=$_POST['Location_of_returning'];
<?php ?>*/
$stmt=$conn->prepare("INSERT INTO `cars321` VALUES ( ?, ?, ? ?, ?, ? ?, ?, ?, ?, ?, ?)");
$stmt->bind_param('ssssssssssss', $_POST['id'], $_POST['start_date'],$_POST['end_date'],$_POST['cars'],$_POST['Location_of_renting'],$_POST['Location_of_returning'], $_POST['vr_uzi'], $_POST['vr_vraca'], $_POST['paid'], $_POST['price'], $_POST['numberdays'], $_POST['Numbers_of_cars']);
/* execute prepared statement */
mysqli_stmt_execute($stmt);
$id = "id";
$start_date= "start_date";
$end_date = "end_date";
$cars= "cars";
$Location_of_renting= "Location_of_renting";
$Location_of_returning= "Location_of_returning";
$vr_uzi= "vr_uzi";
$vr_vraca= "vr_vraca";
$paid= "paid";
$price= "price";
$numberdays= "numberdays";
$Numbers_of_cars= "Numbers_of_cars";
$stmt->execute();
$stmt->execute();
/* close statement and connection */
$stmt->close();
/* Clean up table CountryLanguage */
/* close connection */
$get_max_id =$link->prepare('SELECT start_date, end_date, cars FROM cars321 WHERE id = (SELECT MAX(ID) FROM cars321);');
$query="UPDATE cars321 SET vr_uzi=NOW() WHERE vr_uzi=0000-00-00 00:00:00";
$query="UPDATE cars321 SET vr_vraca=NOW() WHERE vr_vraca=0000-00-00 00:00:00";
$get_max_id->execute();
$get_max_id->fetch();
$get_max_id->close();
/*
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
*/
$conn->close();
}
?>
我们还有更多代码