我的SQL查询中有任何错误吗?插入数据无效

时间:2019-05-29 11:53:49

标签: php mysql

我想将数据插入到数据数据不存在但SQL查询不起作用的表中。我找不到为什么它不起作用。我该怎么办?

$errors    = array();
if(empty($WRITE_AREA)){
    $errors['write_area_error'] = "Area is required";
} 
if(empty($HOUSE_NUMBER)){
    $errors['house_number_error'] = "House Number is required!";
}else{
    $house_number_check = $con->query("SELECT HOUSE_NUMBER FROM badda_area WHERE HOUSE_NUMBER = '$HOUSE_NUMBER'");
    if($house_number_check->num_rows == 0){

    }else{
        $errors['house_number_error'] = "Sorry this house number is already exist";
        $HOUSE_NUMBER = "";
    }
}
if(empty($WRITE_CORDINATE)){
    $errors['coordinate_error'] = "coordinate is required";
}else if(strlen($WRITE_CORDINATE) < 10){
    $errors['coordinate_error'] = "Your coordinate is not valid";
    $WRITE_CORDINATE = "";
}
if(!empty($WRITE_AREA) && !empty($HOUSE_NUMBER) && !empty($WRITE_CORDINATE)){
    $query = $con->query("INSERT INTO badda_area (WRITE_AREA,HOUSE_NUMBER,WRITE_CORDINATE) VALUES ('$WRITE_AREA','$HOUSE_NUMBER','$WRITE_CORDINATE'");
    if($query){
        echo "<script>alert('your data inserted successfully')</script>";
    }else{
        echo "<script>alert('Sorry query not work')</script>";

0 个答案:

没有答案