I couldn't find any error. I tried the query on phpmyadmin and it works well but when I do in php page, it couldn't update into DB. The following code below:
$registerID = ($_POST['registerID']); $firstName = ucwords(htmlspecialchars($_POST['firstName'])); $lastName = ucwords(htmlspecialchars($_POST['lastName'])); $emailAddress = htmlspecialchars($_POST['emailAddress']); $mainAddress = ucwords(htmlspecialchars($_POST['fullAddress'])); $updateCity = ucwords($_POST['userCity']); $updateCountry = $_POST['userCountry']; $postalCode = strtoupper(htmlspecialchars($_POST['userZip'])); $profilePic = $_POST['pic']; $updateProf = " UPDATE register_user SET firstName='$firstName', lastName='$lastName', emailAddress='$emailAddress', mainAddress='$mainAddress', registerCity='$updateCity', registerCountry='$updateCountry', postalCode='$postalCode' WHERE registerID = '$registerID'"; if (mysqli_query($mysqli, $updateProf)) { echo "Record updated successfully"; } else { echo "Error updating record: " . mysqli_error($mysqli); } In the end, there are no errors after I updated on the webpage, it just show Record updated successfully. But it didn't update into DB. Any ideas?
UPDATED CODING
$checkProfile = "SELECT * FROM register_user where emailAddress = '$emailAddress'"; $editProfile = mysqli_query($mysqli,$checkProfile); if ($editProfile) { if (mysqli_num_rows($editProfile) > 0) { header("Location: event?error=That name of email has already been taken"); } else { $updateQuery = "UPDATE register_user SET firstName = '$firstName', lastName = '$lastName', emailAddress = '$emailAddress', mainAddress = '$mainAddress', registerCity = '$updateCity', registerCountry = '$updateCountry', postalCode = '$postalCode' WHERE registerID = '$registerID'"; $updateResult = mysqli_query($mysqli,$updateQuery); header("Location: profileUser"); } } After I updated, it still doesn't work after I am using prepared statement. Any ideas?
it didn't insert into DB? your doing an update, why should it insert?