Marc Jansen Marc Jansen - 3 months ago 17
MySQL Question

Database won't update

My Databsase won't update :(
I don't know why. I tried many things and there is no error report i could read. It should work but it don't. Did I miss something? In order projects it worked too.

<?php
session_start();
$usersession = $_SESSION['session_logged'];

if (isset ($_SESSION["session_logged"])) {

include('db/connection.php');

$res = mysqli_query($con, "select job, status, loan, contactmail, skype from users where username = '$usersession'");

$ja = '0';
$display = mysqli_fetch_assoc($res);

echo "<p><b>Hallo User $usersession</b></p>";
echo "<p>Hier kannst du änderungen an deinem Konto vornehmen.</p>";
echo "<p>Aus sicherheitsgründen kannst du dein Passwort nur mit einem Antrag per Email ändern.</p>";

echo "<form action = 'updatepartner.php' method = 'post'>";

echo "<p><input name='job' value='" . $display["job"] . "' /> Deine Job Bezeichnung</p>";
echo "<p>Zurzeit Verfügbar?</p>";

echo "<p><input type='radio' name='ja' value='2' />Ja</p>";
echo "<p><input type='radio' name='nein' value='0' />Nein</p>";

echo "<p><input name='loan' value='" . $display["loan"] . "' /> Was du für deine Arbeit verlangst</p>";
echo "<p><input name='contactmail' value='" . $display["contactmail"] . "' /> Deine Kontakt E-Mail.</p>";
echo "<p><input name='skype' value='" . $display["skype"] . "' /> Dein Skype Name</p>";
echo "<p><input name='send' type='submit' value='Änderungen speichern' />";
echo " <input type='reset' /></p>";
echo "</form>";

} else {
echo '<p>Melde dich an um dein Partnerkonto zu bearbeiten.</p>';
}


?>


This is the php where all start.
And this should enter the Values in the DB... but it don't work. no Errors!

<?php
session_start();
$usersession = $_SESSION['session_logged'];
include('db/connection.php');

if (empty($_POST['ja'])) {
$ja = '0';
}


$nein = '0';

if ($ja == '2') {
$status = '1';
} else {
$status = $nein;
}


if (isset($_POST["send"])) {
$updateall = "UPDATE users set"
. " job = '" . $_POST['job'] . "'"
. " status = '" . $status . "'"
. " loan = '" . $_POST['loan'] . "'"
. " contactmail = '" . $_POST['contactmail'] . "'"
. " skype = '" . $_POST['skype'] . "'"
. " where username = MarcJansen";

mysqli_query($con, $updateall);
}

print_r($updateall);

echo "</br>";
echo "<a href='partnerbereich.php'>Zurück</a>";


Help :(

Answer

You missed lots of comma(,) in the update statement

$updateall = "UPDATE users set"
." job = '" . $_POST['job'] . "'," 
. " status = '" . $status . "',"
. " loan = '" . $_POST['loan'] . "',"
." contactmail = '" .$_POST['contactmail'] . "'," 
. " skype = '" . $_POST['skype'] . "'" 
. " where username = 'MarcJansen'";