mysqli_stmt_bind_param不能处理时间类型吗?

原创
2016-06-23 13:49:50 1194浏览

报错的这条语句

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


完整代码
 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 '

这条数据已经被添加

'; $_POST = array(); } else { echo '

程序发生错误,请重新添加

'; } mysqli_stmt_close($stmt); } } if ( !empty($errors) && is_array($errors) ) { echo '

发生下列错误:
'; foreach ($errors as $msg) { echo " - $msg
\n"; } echo '请在试一遍

';}?>
住宅数据添加
时间格式例如:2014-12-12
平方



报错提示
出错文件是 'D:\wamp\www\zhuzhai_add.php' 出错行号是 36: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean givenDate/Time: 9-11-2014 03:52:53Array(    [_GET] => Array        (        )    [_POST] => Array        (            [wdate] => 2014-09-11            [city] => 1            [taoshu] => 50            [area] => 10000            [submit] =>         )    [_COOKIE] => Array        (        )    [_FILES] => Array        (        )    [_ENV] => Array        (        )    [_REQUEST] => Array        (            [wdate] => 2014-09-11            [city] => 1            [taoshu] => 50            [area] => 10000            [submit] =>         )


回复讨论(解决方案)

你的$conn 在哪初始化的? 且inser 语句的字段与值个数没匹配上吧。

mysqli_stmt_bind_param($stmt, 'idi s', $c, $a, $t, $w);

你的$conn 在哪初始化的? 且inser 语句的字段与值个数没匹配上吧。


$conn是数据库连接
insert的确多了一个?,但是还是会报错

mysqli_stmt_bind_param($stmt, 'idi s', $c, $a, $t, $w);


修改成s也报错

你的$conn 在哪初始化的? 且inser 语句的字段与值个数没匹配上吧。


贴出修改后的sql串和错误信息

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。