mysqli_stmt_bind_param不能处理时间类型吗?解决思路

WBOY
Release: 2016-06-13 12:06:26
Original
1436 people have browsed it

mysqli_stmt_bind_param不能处理时间类型吗?
 报错的这条语句

mysqli_stmt_bind_param($stmt, 'idii', $c, $a, $t, $w);
Copy after login


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



报错提示

出错文件是 'D:\wamp\www\zhuzhai_add.php' 出错行号是 36: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template