# [SOLVED] mysqli UPDATE prepared statement not working

## darker

I have some data which I am submitting from an HTML form. It creates a new row in the database for each new user, and if a user resubmits their data, it updates their row instead of creating a new one. I'm using MySQL prepared statements in PHP, all the UPDATE statements except for the first seem to have no effect. Here's a sampling of the code.

```

$mysqli = new mysqli("localhost", "xxxx", "xxxxx", "jobapp");

/* if netID already exists in database, update that application. otherwise make new application */

$result = $mysqli->query("SELECT netID FROM personalInfo WHERE netID = '$netID'");

$row = $result->fetch_row();

echo $row[0];

// CREATE A NEW APPLICATION

if ($row[0] != $netID) {

    /* personalInfo */ 

    $stmt1 = $mysqli->prepare("INSERT INTO personalInfo (firstName, lastName, NUID, netID, address, phone, email, workstudy, international, visaType, socialCard, nuJob, commitments, hobbies, date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");

    $stmt1->bind_param('ssissssiisiisss', $firstName, $lastName, $nuid, $netID, $address, $phone, $email,   $workstudy, $international, $visaType, $socialCard, $nuJob, $commitments, $hobbies, $date);

    $stmt1->execute();

    $stmt1->close();

    /* jobPreferences */

    $stmt2 = $mysqli->prepare("INSERT INTO jobPreferences (labCon, SCV, mediaworks, twoEastCon, hoursPerWeek, netID, backupList, hearAboutUs) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");

    $stmt2->bind_param('iiiissis', $labCon, $scv, $mediaworks, $twoEast, $hoursWeek, $netID, $backupList, $hearAboutUs);

    $stmt2->execute();

    $stmt2->close();

}

// EDIT AN APPLICATION

else {

    /* personalInfo */ 

    $stmt14 = $mysqli->prepare("UPDATE personalInfo SET firstName = ?, lastName = ?, NUID = ?, address = ?, phone = ?, email = ?, workstudy = ?, international = ?, visaType = ?, socialCard = ?, nuJob = ?, commitments = ?, hobbies = ?, date = ? WHERE netID = ?");

    $stmt14->bind_param('ssisssiisiisssi', $firstName, $lastName, $nuid, $address, $phone, $email,   $workstudy, $international, $visaType, $socialCard, $nuJob, $commitments, $hobbies, $date, $netID);

    $stmt14->execute();

    $stmt14->close();

    /* jobPreferences */

    echo $backupList;

    $stmt15 = $mysqli->prepare("UPDATE jobPreferences SET labCon = ?, SCV = ?, mediaworks = ?, twoEastCon = ?, hoursPerWeek = ?, backupList = ?, hearAboutUs = ? WHERE netID = ?");

    $stmt15->bind_param('iiiisiss', $labCon, $scv, $mediaworks, $twoEast, $hoursWeek, $backupList, $hearAboutUs, $netID);

    $stmt15->execute();

    $stmt15->close();

}

```

The UPDATE statements which aren't working are not giving an sort of error. I have checked to make sure I am entering the 2nd phase of the if...else. Also, the variables are being set properly from the HTML form, they just are not getting updated in the database.

----------

