Mysql database cannot add NULL values. how can this problem be solved?

Source: Internet
Author: User
Mysql databases cannot add NULL values for data verification, but cannot add NULL values for data. the following error is returned: Column & nbsp; loumiandijia & nbsp; cannot & nbsp; be & nbsp; null other data cannot be used when it is NULL. the code is as follows & lt ;? Phprequire & nbsp; (incconfig. php); $ page_title & nbsp; a NULL value cannot be added to the mysql database.
The data has been verified, but the NULL value cannot be added to the data. the following error is returned:
Column 'loumiandijia' cannot be null

Other data cannot be used if it is NULL.

The code is as follows:
 Require ('Inc/config. php ');
$ Page_title = 'add residential data-feige datacenter ';
Include ('Inc/header. php ');
Require (MYSQL );
If ($ _ SERVER ['request _ method'] = 'post '){
$ Trimmed = array_map ('trim', $ _ POST );
$ Errors = array ();
If (! Empty ($ trimmed ['tudi _ id']) {
$ Tudi_id = mysqli_real_escape_string ($ conn, $ trimmed ['tudi _ id']);
} Else {
$ Errors [] = 'block number cannot be blank ';
}
If (isset ($ trimmed ['city']) & filter_var ($ trimmed ['city'], FILTER_VALIDATE_INT, array ('city' => 1 ))){
$ City = mysqli_real_escape_string ($ conn, $ trimmed ['city']);
} Else {
$ Errors [] = 'Select a region ';
}
$ Weizhi = (! Empty ($ trimmed ['weizhi'])? Mysqli_real_escape_string ($ conn, $ trimmed ['weizhi']): NULL;
$ Yongtu = (! Empty ($ trimmed ['yongtu'])? Mysqli_real_escape_string ($ conn, $ trimmed ['yongtu']): NULL;
$ Rongjilv = (! Empty ($ trimmed ['rongjilv'])? Mysqli_real_escape_string ($ conn, $ trimmed ['rongjilv']): NULL;
$ Midu = (! Empty ($ trimmed ['midu'])? Mysqli_real_escape_string ($ conn, $ trimmed ['midu']): NULL;
$ Lvdi = (! Empty ($ trimmed ['lvdi '])? Mysqli_real_escape_string ($ conn, $ trimmed ['lvdi ']): NULL;
If (empty ($ trimmed ['fabu _ time']) {
$ Errors [] = 'publication date cannot be blank ';
} Else {
$ Fabu_time = mysqli_real_escape_string ($ conn, $ trimmed ['fabu _ time']);
}
If (empty ($ trimmed ['chengjiao _ time']) {
$ Errors [] = 'transaction date cannot be blank ';
} Else {
$ Chengjiao_time = mysqli_real_escape_string ($ conn, $ trimmed ['chengjiao _ time']);
}
If (empty ($ trimmed ['jiezhi _ time']) {
$ Errors [] = 'margin deadline cannot be blank ';
} Else {
$ Jiezhi_time = mysqli_real_escape_string ($ conn, $ trimmed ['jiezhi _ time']);
}
If (is_numeric ($ trimmed ['baozhengjin']) & ($ trimmed ['baozhengjin']> 0 )){
$ Baozhengjin = mysqli_real_escape_string ($ conn, (float) $ trimmed ['baozhengjin']);
} Else {
$ Errors [] = 'enter a correct bidding deposit (CNY )';
}
If (is_numeric ($ trimmed ['mianji _ m']) & ($ trimmed ['mianji _ m']> 0 )){
$ Mianji_m = mysqli_real_escape_string ($ conn, (float) $ trimmed ['mianji _ m']);
} Else {
$ Errors [] = 'enter a correct floor space (mu )';
}
If (is_numeric ($ trimmed ['mianji _ p']) & ($ trimmed ['mianji _ p']> 0 )){
$ Mianji_p = mysqli_real_escape_string ($ conn, (float) $ trimmed ['mianji _ p']);
} Else {
$ Errors [] = 'enter a correct footprint ';
}
If (is_numeric ($ trimmed ['guihua _ p']) & ($ trimmed ['guihua _ p']> 0 )){
$ Guihua_p = mysqli_real_escape_string ($ conn, (float) $ trimmed ['guihua _ p']);
} Else {
$ Errors [] = 'enter a correct planned building area ';
}
If (is_numeric ($ trimmed ['qipaijia ']) & ($ trimmed ['qipaijia']> 0 )){
$ Qipaijia = mysqli_real_escape_string ($ conn, (float) $ trimmed ['qipaijia ']);
} Else {
$ Errors [] = 'enter a correct starting price (10 thousand/acre )';
}
$ Chengjiaodanjia = (! Empty ($ trimmed ['chengjiaodanjia '])? Mysqli_real_escape_string ($ conn, (float) $ trimmed ['chengjiaodanjia ']): NULL;
$ Chengjiazongjia = (! Empty ($ trimmed ['chengjiazongjia '])? Mysqli_real_escape_string ($ conn, (float) $ trimmed ['chengjiazongjia ']): NULL;
$ Loumiandijia = (! Empty ($ trimmed ['loumiandijia '])? Mysqli_real_escape_string ($ conn, (float) $ trimmed ['loumiandijia ']): NULL;
$ Yijialv = (! Empty ($ trimmed ['yijialv'])? Mysqli_real_escape_string ($ conn, $ trimmed ['yijialv']): NULL;
$ Jingderen = (! Empty ($ trimmed ['jingderen'])? Mysqli_real_escape_string ($ conn, $ trimmed ['jingderen']): NULL;
$ Chilang_p = (! Empty ($ trimmed ['Church _ p'])? Mysqli_real_escape_string ($ conn, (float) $ trimmed ['Church _ p']): NULL;
$ Dituweizhi = (! Empty ($ trimmed ['dituweizhi'])? Mysqli_real_escape_string ($ conn, $ trimmed ['dituweizhi']): NULL;
$ Xuzhi = (! Empty ($ trimmed ['xuzhi'])? Mysqli_real_escape_string ($ conn, $ trimmed ['xuzhi']): NULL;
If (isset ($ trimmed ['is _ Cheng']) & is_numeric ($ trimmed ['is _ Cheng']) & ($ trimmed ['is _ Cheng']> = 0 )){
$ Is_cheng = mysqli_real_escape_string ($ conn, $ trimmed ['is _ Cheng']);
} Else {
$ Errors [] = 'SELECT whether the transaction is successful ';
}

If (empty ($ errors )){
$ Q = 'Insert INTO f_tudi (tudi_id, city_id, weizhi, yongtu, rongjilv, midu, lvdi, fabu_time, hour, hour, baozhengjin, hour, qipaijia, temperature, chengjiazongjia, loumiandijia, yijialv, jingderen, chilang_p, dituweizhi, xuzhi, is_cheng) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ';

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.