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

WBOY
发布: 2016-06-13 12:06:26
原创
1437 人浏览过

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

mysqli_stmt_bind_param($stmt, 'idii', $c, $a, $t, $w);
登录后复制


完整代码
<?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 />?>
登录后复制



报错提示

出错文件是 'D:\wamp\www\zhuzhai_add.php' 出错行号是 36: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given<div class="clear">
                 
              
              
        
            </div>
登录后复制
相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板