Page 1 of 1

Getting UPDATE query to affect the MySQL DB

Posted: Tue Sep 01, 2009 1:27 pm
by phpBever
All my other queries seem to run fine. This one seems to run without any error, but it doesn't introduce any changes into the DB:

Code: Select all

$stud_name = $_POST['stud_name'];
$stud_id = $_POST['stud_id'];
$password = $_POST['password'];
$email = $_POST['email'];
$username = $_POST['username'];
//submit changes to DB
 
$sqlSubmitChanges = "UPDATE tblStudent 
            SET stud_name ='$stud_name',
                username = '$username',
                email = '$email'
            WHERE stud_id = '$studentID'";
    $resSubmitChanges = mysqli_query($mysqli, $sqlSubmitChanges) or die(mysqli_error($mysqli));
I'm populating my form with the existing DB info; I let the user (me, for now) change one or another field. When the form is now submitted, the update query is supposed to run. It seems to run--I get no error message. But the DB info is not updated.

What am I missing? (I took the password line out of the update query just in case I didn't have that syntax right, but it still doesn't run.)

Thanks.

Re: Getting UPDATE query to affect the MySQL DB

Posted: Tue Sep 01, 2009 1:29 pm
by phpBever
PS--
I've checked the values of the $_POST variables I'm getting and they are correct.

Re: Getting UPDATE query to affect the MySQL DB

Posted: Tue Sep 01, 2009 2:19 pm
by Darhazer
You are using the undefined variable $studentID instead of $stud_id

Re: Getting UPDATE query to affect the MySQL DB

Posted: Tue Sep 01, 2009 2:44 pm
by phpBever
:(

Thanks. Sorry I didn't see that.