当前位置:Gxlcms > PHP教程 > mysqli_stmt_bind_param不能处理时间类型吗?解决思路

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

时间:2021-07-01 10:21:17 帮助过:7人阅读

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 '请在试一遍

';
}

?>

住宅数据添加




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



报错提示
出错文件是 'D:\wamp\www\zhuzhai_add.php' 出错行号是 36: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given                    

人气教程排行