SQL查询有时无法运行

时间:2018-07-19 07:34:24

标签: php mysqli

我的PHP网站存在问题。该查询正常运行,并且每当我更新相关文件中的PHP代码时,它就会向我显示错误。我已经检查了很多次,但是没有代码错误,因为在更新文件之前,相同的代码可以正常工作,但是现在更新文件后,它显示SQL查询错误。

我的代码是:

if($user_profile_pic_name == ''){
    $ipq = "UPDATE `abc` 
            SET `abc_email`= '$user_email', 
                `abc_pwd`= '$user_pass', 
                `abc_looking_for` = '$looking_for', 
                `abc_for_my` = '$for_my', 
                `abc_gender` = '$gender', 
                `abc_marital_status` = '$marital_status', 
                `abc_category` = '$proposal_category', 
                `abc_disability` = '$disability', 
                `abc_disability_details` = '$disability_details', 
                `abc_full_name` = '$user_fullname', 
                `abc_age` = '$user_age', 
                `abc_height` = '$user_height', 
                `abc_nationality` = '$nationality', 
                `abc_residence` = '$residence', 
                `abc_city` = '$city', 
                `abc_hometown` = '$hometown', 
                `abc_religion` = '$religion', 
                `abc_main_sect` = '$religion_main_sect', 
                `abc_sub_sect` = '$religion_sub_sect', 
                `abc_caste` = '$caste', 
                `abc_degree_level` = '$deglev', 
                `abc_program` = '$program', 
                `abc_profession` = '$profession', 
                `abc_cnic_pass` = '$user_cnic_passport', 
                `abc_fb_link` = '$user_fblink', 
                `abc_bio` = '$biography', 
                `abc_required_age` = '$req_age', 
                `abc_required_height` = '$req_height', 
                `abc_required_caste` = '$req_caste', 
                `abc_required_detail` = '$req_specific_requirement', 
                `abc_hobbies` = '$hobbies', 
                `abc_siblings` = '$siblings', 
                `abc_siblings_marital_status` = '$siblings_marital_status', 
                `abc_father_occupation` = '$father_occu', 
                `abc_mother_occupation` = '$mother_occu', 
                `abc_mobile_number` = '$mobile_number', 
                `abc_phone_number` = '$phone_number', 
                `abc_office_number` = '$office_number', 
                `abc_register_date` = '$reg_date', 
                `abc_amount_paid` = '$reg_paid', 
                `abc_remaining` = '$reg_remaining', 
                `abc_status` = '$account_status', 
                `abc_paid_status` = '$paid_status' 
            WHERE abc_id = '$update_id'";
    $rpq = mysqli_query($con, $ipq);

    if($rpq){
        header("location: edit-user.php?edit_id=$update_id&success=" . urlencode("Successfully updated."));
        exit();
    }
    else{
        header("location: edit-user.php?edit_id=$update_id&error=" . urlencode("Sorry, cannot update right now."));
        exit();
    }//ipq query ends here
}

1 个答案:

答案 0 :(得分:-2)

谢谢你们的帮助,我发现的解决方案是:

有多种方法可以解决此错误。就我而言: 1. MySQL查询中的缺失字段-未定位

解决方案: 将数据发送到查询中的表字段时,请勿将任何字段留空 正确检查所有语法,甚至所有这些符号`',