报错的这条语句
mysqli_stmt_bind_param($stmt, 'idii', $c, $a, $t, $w);
完整代码
<?php
require ('inc/config.php');
$page_title = '住宅数据添加-feige数据中心';
include ('inc/header.php');
require (MYSQL);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$trimmed = array_map('trim', $_POST);
$errors = array();
if(empty($trimmed['wdate'])) {
$errors[] = '日期不能为空';
} else {
$w = mysqli_real_escape_string ($conn, $trimmed['wdate']);
}
if ( isset($trimmed['city']) && filter_var($trimmed['city'], FILTER_VALIDATE_INT, array('city' => 1)) ) {
$c = mysqli_real_escape_string ($conn, $trimmed['city']);;
} else {
$errors[] = '请选择区域';
}
if (is_numeric($trimmed['taoshu']) && ($trimmed['taoshu'] > 0)) {
$t = mysqli_real_escape_string ($conn, (int) $trimmed['taoshu']);
} else {
$errors[] = '请输入一个正确的套数';
}
if (is_numeric($trimmed['area']) && ($trimmed['area'] > 0)) {
$a = mysqli_real_escape_string ($conn, (float) $trimmed['area']);
} else {
$errors[] = '请输入一个正确的面积';
}
if (empty($errors)) {
$q = 'INSERT INTO f_chengjiao (city_id, area, taoshu, fang_time, os_time) VALUES (?, ?, ?, ?, ?, NOW())';
$stmt = mysqli_prepare($conn, $q);
mysqli_stmt_bind_param($stmt, 'idii', $c, $a, $t, $w);
mysqli_stmt_execute($stmt);
if (mysqli_stmt_affected_rows($stmt) == 1) {
echo '<p>这条数据已经被添加</p>';
$_POST = array();
} else {
echo '<p style="font-weight: bold; color: #C00">程序发生错误,请重新添加</p>';
}
mysqli_stmt_close($stmt);
}
}
if ( !empty($errors) && is_array($errors) ) {
echo '<p style="font-weight: bold; color: #C00">发生下列错误:<br />';
foreach ($errors as $msg) {
echo " - $msg<br />\n";
}
echo '请在试一遍</p>';
}
?>
<div class="portlet wrap mT50">
<div class="portlet-title">住宅数据添加</div>
<div class="portlet-body">
<form action="zhuzhai_add.php" method="post">
<div class="control-group">
<label class="control-label">时间</label>
<div class="controls">
<input type="text" name="wdate" class="add-in" onClick="WdatePicker()" value="" />时间格式例如:2014-12-12
</div>
</div>
<div class="control-group">
<label class="control-label">区域</label>
<div class="controls">
<select name="city" class="select-city">
<?php
$q = "SELECT city_id, city_name FROM f_city ORDER BY city_id ASC";
$r = mysqli_query ($conn, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($conn));
if (@mysqli_num_rows($r) > 0) {
while ($row = mysqli_fetch_array ($r, MYSQLI_NUM)) {
echo "<option value=\"$row[0]\"";
if (isset($trimmed['city']) && ($trimmed['city'] == $row[0]) ) echo ' selected="selected"';
echo ">$row[1]</option>\n";
}
mysqli_free_result ($r);
} else {
echo '<option>暂无区域,请添加一个新地区</option>';
}
mysqli_close($conn);
?>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label">套数</label>
<div class="controls">
<input type="text" name="taoshu" class="add-in" value="" />套
</div>
</div>
<div class="control-group">
<label class="control-label">面积</label>
<div class="controls">
<input type="text" name="area" class="add-in" value="" />平方
</div>
</div>
<div class="form-actions">
<button class="btn" name="submit" type="submit">提交</button>
</div>
</form>
</div>
</div>
<?php
include ('inc/footer.php');
?>
报错提示
出错文件是 'D:\wamp\www\zhuzhai_add.php' 出错行号是 36: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given