Mysql_query error in PHP

)
I am building a website, but ran into an error… I have a script that is supposed to upload variable values to an sql database. I am using or die(mysql_error()), but i get nothing, as if the mysql is working, but the variables aren’t populated… But i have tried exchanging the variables with plain text, to see the upload – which also didn’t work.

Here’s my code

<?php
include("./header.php");
//Validate login
if(!isset($_SESSION['user_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("INSERT INTO user (meas_neckcircumference,meas_shoulderwidth,meas_sleevelength,meas_bicepcircumference,meas_wristcircumference,meas_bustcircumference,meas_abdomencircumference,meas_torsolength,meas_waistcircumference,meas_hipcircumference,meas_trouserrise,meas_thighcircumference,meas_kneesize,meas_trouserlength,meas_bodytype,meas_shouldertype,meas_stomachtype,meas_height,meas_weight) VALUES ('$neckcircumference','$shoulderwidth','$sleevelength','$bicepcircumference','$wristcircumference','$bustcircumference','$abdomencircumference','$torsolength','$waistcircumference','$hipcircumference','$trouserrise','$thighcircumference','$kneesize','$trouserlength','$bodytype','$shouldertype','$stomachtype','$fullheight','$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
}
?>

Best regards 🙂


Source: mysql

Leave a Reply