mysql数据库不能添加NULL值
数据都验证了,但是不能给数据添加NULL值,报错如下:
Column 'loumiandijia' cannot be null
<?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['tudi_id'])) {<br> $tudi_id = mysqli_real_escape_string ($conn, $trimmed['tudi_id']);<br> } else {<br> $errors[] = '地块编号不能为空';<br> } <br> if ( isset($trimmed['city']) && filter_var($trimmed['city'], FILTER_VALIDATE_INT, array('city' => 1)) ) {<br> $city = mysqli_real_escape_string ($conn, $trimmed['city']);;<br> } else {<br> $errors[] = '请选择区域';<br> }<br> $weizhi = (!empty($trimmed['weizhi'])) ? mysqli_real_escape_string ($conn, $trimmed['weizhi']) : NULL;<br> $yongtu = (!empty($trimmed['yongtu'])) ? mysqli_real_escape_string ($conn, $trimmed['yongtu']) : NULL;<br> $rongjilv = (!empty($trimmed['rongjilv'])) ? mysqli_real_escape_string ($conn, $trimmed['rongjilv']) : NULL;<br> $midu = (!empty($trimmed['midu'])) ? mysqli_real_escape_string ($conn, $trimmed['midu']) : NULL;<br> $lvdi = (!empty($trimmed['lvdi'])) ? mysqli_real_escape_string ($conn, $trimmed['lvdi']) : NULL; <br> if(empty($trimmed['fabu_time'])) {<br> $errors[] = '发布日期不能为空';<br> } else {<br> $fabu_time = mysqli_real_escape_string ($conn, $trimmed['fabu_time']);<br> }<br> if(empty($trimmed['chengjiao_time'])) {<br> $errors[] = '成交日期不能为空';<br> } else {<br> $chengjiao_time = mysqli_real_escape_string ($conn, $trimmed['chengjiao_time']);<br> }<br> if(empty($trimmed['jiezhi_time'])) {<br> $errors[] = '保证金截止时间不能为空';<br> } else {<br> $jiezhi_time = mysqli_real_escape_string ($conn, $trimmed['jiezhi_time']);<br> } <br> if (is_numeric($trimmed['baozhengjin']) && ($trimmed['baozhengjin'] > 0)) {<br> $baozhengjin = mysqli_real_escape_string ($conn, (float) $trimmed['baozhengjin']);<br> } else {<br> $errors[] = '请输入一个正确的竞买保证金(万元)';<br> }<br> if (is_numeric($trimmed['mianji_m']) && ($trimmed['mianji_m'] > 0)) {<br> $mianji_m = mysqli_real_escape_string ($conn, (float) $trimmed['mianji_m']);<br> } else {<br> $errors[] = '请输入一个正确的占地面积(亩)';<br> }<br> if (is_numeric($trimmed['mianji_p']) && ($trimmed['mianji_p'] > 0)) {<br> $mianji_p = mysqli_real_escape_string ($conn, (float) $trimmed['mianji_p']);<br> } else {<br> $errors[] = '请输入一个正确的占地面积';<br> }<br> if (is_numeric($trimmed['guihua_p']) && ($trimmed['guihua_p'] > 0)) {<br> $guihua_p = mysqli_real_escape_string ($conn, (float) $trimmed['guihua_p']);<br> } else {<br> $errors[] = '请输入一个正确的规划建筑面积';<br> }<br> if (is_numeric($trimmed['qipaijia']) && ($trimmed['qipaijia'] > 0)) {<br> $qipaijia = mysqli_real_escape_string ($conn, (float) $trimmed['qipaijia']);<br> } else {<br> $errors[] = '请输入一个正确的起拍价(万/亩)';<br> }<br> $chengjiaodanjia = (!empty($trimmed['chengjiaodanjia'])) ? mysqli_real_escape_string ($conn, (float) $trimmed['chengjiaodanjia']) : NULL;<br> $chengjiazongjia = (!empty($trimmed['chengjiazongjia'])) ? mysqli_real_escape_string ($conn, (float) $trimmed['chengjiazongjia']) : NULL;<br> $loumiandijia = (!empty($trimmed['loumiandijia'])) ? mysqli_real_escape_string ($conn, (float) $trimmed['loumiandijia']) : NULL;<br> $yijialv = (!empty($trimmed['yijialv'])) ? mysqli_real_escape_string ($conn, $trimmed['yijialv']) : NULL;<br> $jingderen = (!empty($trimmed['jingderen'])) ? mysqli_real_escape_string ($conn, $trimmed['jingderen']) : NULL;<br> $churang_p = (!empty($trimmed['churang_p'])) ? mysqli_real_escape_string ($conn, (float) $trimmed['churang_p']) : NULL;<br> $dituweizhi = (!empty($trimmed['dituweizhi'])) ? mysqli_real_escape_string ($conn, $trimmed['dituweizhi']) : NULL;<br> $xuzhi = (!empty($trimmed['xuzhi'])) ? mysqli_real_escape_string ($conn, $trimmed['xuzhi']) : NULL;<br> if ( isset($trimmed['is_cheng']) && is_numeric($trimmed['is_cheng']) && ($trimmed['is_cheng'] >= 0) ) {<br> $is_cheng = mysqli_real_escape_string ($conn, $trimmed['is_cheng']);;<br> } else {<br> $errors[] = '请选择交易是否成功';<br> } <br> <br> if (empty($errors)) {<br> $q = 'INSERT INTO f_tudi (tudi_id, city_id, weizhi, yongtu, rongjilv, midu, lvdi, fabu_time, chengjiao_time, jiezhi_time, baozhengjin, mianji_m, mianji_p, guihua_p, qipaijia, chengjiaodanjia, chengjiazongjia, loumiandijia, yijialv, jingderen, churang_p, dituweizhi, xuzhi, is_cheng) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';<div class="clear"> </div>