Mysql_query string not updating

I am having problems with my code:

<?php
include("./header.php");
//Validate login
if(!isset($_SESSION['user_id']) && !isset($_SESSION['invite_id'])) {
    echo "<meta http-equiv=\"refresh\" content=\"0; url=/\">";
}
else {
    $user_login = $_SESSION['user_login'];
    //Get whether user clicked submit
    $submitSuitDesignCredentials = $_POST['submitSuitDesignCredentials'];
    if (isset($submitSuitDesignCredentials)) {
        //Store user input in variables and remove unwanted characters
       $neckcircumference = preg_replace('#[^0-9.,]#i','', $_POST['neckcircumference']);
       $shoulderwidth = preg_replace('#[^0-9.,]#i','', $_POST['shoulderwidth']);
       $sleevelength = preg_replace('#[^0-9.,]#i','', $_POST['sleevelength']);
       $bicepcircumference = preg_replace('#[^0-9.,]#i','', $_POST['bicepcircumference']);
       $wristcircumference = preg_replace('#[^0-9.,]#i','', $_POST['wristcircumference']);
       $bustcircumference = preg_replace('#[^0-9.,]#i','', $_POST['bustcircumference']);
       $lowerribcircumference = preg_replace('#[^0-9.,]#i','', $_POST['lowerribcircumference']);
       $abdomencircumference = preg_replace('#[^0-9.,]#i','', $_POST['abdomencircumference']);
       $torsolength = preg_replace('#[^0-9.,]#i','', $_POST['torsolength']);
       $waistcircumference = preg_replace('#[^0-9.,]#i','', $_POST['waistcircumference']);
       $hipcircumference = preg_replace('#[^0-9.,]#i','', $_POST['hipcircumference']);
       $trouserrise = preg_replace('#[^0-9.,]#i','', $_POST['trouserrise']);
       $thighcircumference = preg_replace('#[^0-9.,]#i','', $_POST['thighcircumference']);
       $kneesize = preg_replace('#[^0-9.,]#i','', $_POST['kneesize']);
       $trouserlength = preg_replace('#[^0-9.,]#i','', $_POST['trouserlength']);
       $bodytype = preg_replace('#[^A-Za-z]#i','', $_POST['bodytype']);
       $shouldertype = preg_replace('#[^A-Za-z]#i','', $_POST['shouldertype']);
       $stomachtype = preg_replace('#[^A-Za-z]#i','', $_POST['stomachtype']);
       $fullheight = preg_replace('#[^0-9.,]#i','', $_POST['fullheight']);
       $weight = preg_replace('#[^0-9.,]#i','', $_POST['weight']);
        //Upload to database
        mysql_query("UPDATE user SET meas_neckcircumference='$neckcircumference',meas_shoulderwidth='$shoulderwidth',meas_sleevelength='$shoulderwidth',meas_bicepcircumference='$bicepcircumference',meas_wristcircumference='$wristcircumference',meas_bustcircumference='$bustcircumference',meas_abdomencircumference='$bustcircumference',meas_torsolength='$torsolength',meas_waistcircumference='$waistcircumference',meas_hipcircumference='$hipcircumference',meas_trouserrise='$trouserrise',meas_thighcircumference='$thighcircumference',meas_kneesize='$kneesize',meas_trouserlength='$trouserlength',meas_bodytype='$bodytype',meas_shouldertype='$shouldertype',meas_stomachtype='$stomachtype',meas_height='$fullheight',meas_weight='$weight') WHERE email='$user_login'") or die(mysql_error());
    }
    ?>
        <div class="headlineContainer">
            <h1>Din målprofil</h1>
        </div>
        <h2>Kropsmål</h2>
        <form id="measurementProfile" action="" method="POST">
        <div class="subContentContainer">
            <table>
               <tr>
                    <td><h4>Hals omkreds</h4></td>
                    <td><input type="text" placeholder="CM" id="neckcircumference" name="neckcircumference"></input></td>
                    <td><h4>Skulderbredde</h4></td>
                    <td><input type="text" placeholder="CM" id="shoulderwidth" name="shoulderwidth"></input></td>
                    <td><h4>Ærmelængde</h4></td>
                    <td><input type="text" placeholder="CM" id="sleevelength" name="sleevelength"></input></td>
                </tr>
                <tr>
                    <td><h4>Bicep omkreds</h4></td>
                    <td><input type="text" placeholder="CM" id="bicepcircumference" name="bicepcircumference"></input></td>
                    <td><h4>Håndled omkreds</h4></td>
                    <td><input type="text" placeholder="CM" id="wristcircumference" name="wristcircumference"></input></td>
                    <td><h4>Bryst omkreds</h4></td>
                    <td><input type="text" placeholder="CM" id="bustcircumference" name="bustcircumference"></input></td>
                </tr>
                <tr>
                    <td><h4>Bundribben omkreds</h4></td>
                    <td><input type="text" placeholder="CM" id="lowerribcircumference" name="lowerribcircumference"></input></td>
                    <td><h4>Mave omkreds</h4></td>
                    <td><input type="text" placeholder="CM" id="abdomencircumference" name="abdomencircumference"></input></td>
                    <td><h4>Overkrop længde</h4></td>
                    <td><input type="text" placeholder="CM" id="torsolength" name="torsolength"></input></td>
                </tr>
                <tr>
                    <td><h4>Talje omkreds</h4></td>
                    <td><input type="text" placeholder="CM" id="waistcircumference" name="waistcircumference"></input></td>
                    <td><h4>Hofte omkreds</h4></td>
                    <td><input type="text" placeholder="CM" id="hipcircumference" name="hipcircumference"></input></td>
                    <td><h4>Bukseskridt højde</h4></td>
                    <td><input type="text" placeholder="CM" id="trouserrise" name="trouserrise"></input></td>
                </tr>
                <tr>
                    <td><h4>Lår omkreds</h4></td>
                    <td><input type="text" placeholder="CM" id="thighcircumference" name="thighcircumference"></input></td>
                    <td><h4>Knæ størrelse</h4></td>
                    <td><input type="text" placeholder="CM" id="kneesize" name="kneesize"></input></td>
                    <td><h4>Benlængde</h4></td>
                    <td><input type="text" placeholder="CM" id="trouserlength" name="trouserlength"></input></td>
                </tr>
                <tr>
                    <td><h4>Højde</h4></td>
                    <td><input type="text" placeholder="CM" id="fullheight" name="fullheight"></input></td>
                    <td><h4>Vægt</h4></td>
                    <td><input type="text" placeholder="KG" id="weight" name="weight"></input></td>
                </tr>
            </table>
        </div>
        <h2>Kropstype</h2>
        <div class="subContentContainer">
            <table>
                <tr>
                    <td><h4>Figur</h4></td>
                    <td><input type="radio" id="bodytypeRadio1" name="bodytype" value="slim"><label for="bodytypeRadio1">Flad krop</label></td>
                    <td><input type="radio" id="bodytypeRadio2" name="bodytype" value="average"><label for="bodytypeRadio2">Normal krop</label></td>
                    <td><input type="radio" id="bodytypeRadio3" name="bodytype" value="slightlyoverweight"><label for="bodytypeRadio3">Lidt overvægtig krop</label></td>
                    <td><input type="radio" id="bodytypeRadio4" name="bodytype" value="overweight"><label for="bodytypeRadio4">Overvægtig krop</label></td>
                    <td><input type="radio" id="bodytypeRadio5" name="bodytype" value="muscular"><label for="bodytypeRadio5">Muskuløs krop</label></td>
                </tr>
                <tr>
                    <td><h4>Skuldre</h4></td>
                    <td><input type="radio" id="shouldertypeRadio1" name="shouldertype" value="highshoulders"><label for="shouldertypeRadio1">Høje skuldre</label></td>
                    <td><input type="radio" id="shouldertypeRadio2" name="shouldertype" value="average"><label for="shouldertypeRadio2">Normale skuldre</label></td>
                    <td><input type="radio" id="shouldertypeRadio3" name="shouldertype" value="lowshoulders"><label for="shouldertypeRadio3">Lave skuldre</label></td>
                </tr>
                <tr>
                    <td><h4>Mave</h4></td>
                    <td><input type="radio" id="stomachtypeRadio1" name="stomachtype" value="plain"><label for="stomachtypeRadio1">Flad mave</label></td>
                    <td><input type="radio" id="stomachtypeRadio2" name="stomachtype" value="slightlyconvex"><label for="stomachtypeRadio2">Lidt konveks mave</label></td>
                    <td><input type="radio" id="stomachtypeRadio3" name="stomachtype" value="convex"><label for="stomachtypeRadio3">Konveks mave</label></td>
                </tr>
            </table>
        </div>
        <input type="submit" name="submitMeasurementProfile" id="submit" value="Opdater dine mål"></input>
        </form>
<?php
}
?>

      

The problem is here:

mysql_query("UPDATE user SET meas_neckcircumference='$neckcircumference',meas_shoulderwidth='$shoulderwidth',meas_sleevelength='$shoulderwidth',meas_bicepcircumference='$bicepcircumference',meas_wristcircumference='$wristcircumference',meas_bustcircumference='$bustcircumference',meas_abdomencircumference='$bustcircumference',meas_torsolength='$torsolength',meas_waistcircumference='$waistcircumference',meas_hipcircumference='$hipcircumference',meas_trouserrise='$trouserrise',meas_thighcircumference='$thighcircumference',meas_kneesize='$kneesize',meas_trouserlength='$trouserlength',meas_bodytype='$bodytype',meas_shouldertype='$shouldertype',meas_stomachtype='$stomachtype',meas_height='$fullheight',meas_weight='$weight') WHERE email='$user_login'") or die(mysql_error());

      

I was recently told that I should use the above line of code and it should work ... But it doesn't! die

does not return an error and the string itself is not loaded into the db.

Sincerely, Victor

+3


source to share


2 answers


Your query never runs. You validate $_POST['submitSuitDesignCredentials']

, but your form submits$_POST['submitMeasurementProfile']



+2


source


You had an irrelevant place ) over

meas_weight='$weight') WHERE email='$user_login'
                    ^^^

      



remove this paranthesis as

meas_weight='$weight' WHERE email='$user_login'

      

+2


source







All Articles