PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

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

原创
2016-06-13 12:06:26 1201浏览

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

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


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

这条数据已经被添加

';
$_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

















平方








include ('inc/footer.php');
?>



报错提示
出错文件是 'D:\wamp\www\zhuzhai_add.php' 出错行号是 36: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。