Getting UPDATE query to affect the MySQL DB

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
phpBever
Forum Commoner
Posts: 42
Joined: Fri Aug 07, 2009 10:23 am

Getting UPDATE query to affect the MySQL DB

Post 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.
phpBever
Forum Commoner
Posts: 42
Joined: Fri Aug 07, 2009 10:23 am

Re: Getting UPDATE query to affect the MySQL DB

Post by phpBever »

PS--
I've checked the values of the $_POST variables I'm getting and they are correct.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: Getting UPDATE query to affect the MySQL DB

Post by Darhazer »

You are using the undefined variable $studentID instead of $stud_id
phpBever
Forum Commoner
Posts: 42
Joined: Fri Aug 07, 2009 10:23 am

Re: Getting UPDATE query to affect the MySQL DB

Post by phpBever »

:(

Thanks. Sorry I didn't see that.
Post Reply