0

我正在尝试使用一个包含多个设置值的 sql 语句来更新我的数据库表。我遇到了意外的 $end 错误,但似乎无法弄清楚我错过了什么。任何关于我可能错过的或更好的方法的输入将不胜感激。

if($_SERVER["REQUEST_METHOD"] == "GET")
{

}
else if($_SERVER["REQUEST_METHOD"] == "POST")
{
    $conn = db_connect();

    if (strlen($_POST['dEtag']) > 150 || strlen($_POST['dEtag'] < 1) || strlen($_POST['userDescription'] < 1 || strlen($_POST['matchDescription'] < 1)))
    {
        echo "<h1> You must enter a dEtag, description and match description! <h1>";
    }
    else
    {
        if (isset($_POST['updateAll']))
        {
            $sql = "UPDATE profiles SET body_type = '".$_POST['body']."', smoke = '" . $_POST['smoke'] ."', drink = '" . $_POST['drink'] ."',
            drugs = '" . $_POST['drugs'] ."', religion = '" . $_POST['religion'] ."', education = '" . $_POST['education'] ."',
            income = '" . $_POST['income'] ."', vehicle = '" . $_POST['vehicle'] ."', has_children = '" . $_POST['children'] ."',
            match_body_type = '".$_POST['mateBody']."', match_smoke = '" . $_POST['mateSmoke'] ."', match_drink = '" . $_POST['mateDrink'] ."',
            match_drugs = '" . $_POST['mateDrugs'] ."', match_religion = '" . $_POST['mateReligion'] ."',
            match_education = '" . $_POST['mateEducation'] ."', match_income = '" . $_POST['mateIncome'] ."',
            match_vehicle = '" . $_POST['mateVehicle'] ."', match_has_children ='" . $_POST['matesChildren'] ."',
            headline = '" . $_POST['deTag'] . "', self_description = '" . $_POST['description'] . "', match_description = '" . $_POST['hobbies'] . "'
            WHERE user_id ='. '". $_SESSION['user'] ."'";

        }
        else if (isset($_POST['updatePersonal']))
        {
            $sql = "UPDATE profiles SET body_type = '".$_POST['body']."', smoke = '" . $_POST['smoke'] ."', drink = '" . $_POST['drink'] ."',
            drugs = '" . $_POST['drugs'] ."', religion = '" . $_POST['religion'] ."', education = '" . $_POST['education'] ."',
            income = '" . $_POST['income'] ."', vehicle = '" . $_POST['vehicle'] ."', has_children = '" . $_POST['children'] ."'
            WHERE user_id ='. '". $_SESSION['user'] ."'";
        }
        else if (isset($_POST['updateMate']))
        {
            $sql = "UPDATE profiles SET match_body_type = '".$_POST['mateBody']."', match_smoke = '" . $_POST['mateSmoke'] ."', match_drink = '" . $_POST['mateDrink'] ."',
            match_drugs = '" . $_POST['mateDrugs'] ."', match_religion = '" . $_POST['mateReligion'] ."',
            match_education = '" . $_POST['mateEducation'] ."', match_income = '" . $_POST['mateIncome'] ."',
            match_vehicle = '" . $_POST['mateVehicle'] ."', match_has_children ='" . $_POST['matesChildren'] ."' WHERE user_id ='. '". $_SESSION['user'] ."'";
        }
        else if (isset($_POST['']))
        {
            $sql = "UPDATE profiles SET headline = '" . $_POST['deTag'] . "', self_description = '" . $_POST['userDescription'] . "', match_description = '" . $_POST['matchDescription'] . "'
            WHERE user_id ='. '". $_SESSION['user'] ."'";
        }
        pg_query($conn, $sql);

        echo "<h1>'". $_SESSION['user'] ."', Your Profile Updated Successfully!</h1>";
    }
4

0 回答 0