Hi all, I'm messing around trying to learn more about db interactions and I have an "edit" page which pulls user info and populates it into text fields for editing/updating the db.
If I make any change to the values and submit, I don't get any errors an my updates show up in the db, so all is good there.
If I just submit without making any changes, my else branch is hit, so mysql_affected_rows is not reporting a row affected, even though aren't I replacing the values in the db with the exact same values? Shouldn't that still report that row being updated?
Code://if no errors UPDATE DB if (empty($errors)) { $query = "UPDATE users SET first_name='$firstname', last_name='$lastname', email='$email', state='$state'"; //if changing password if($newpass1){ $query .= ", pass=md5('$newpass1')"; } $query .= " WHERE user_id = {$_SESSION['user_id']}"; $result = @mysql_query($query, $dbc) OR trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error($dbc)); if (mysql_affected_rows($dbc) == 1) { //if it ran ok echo $query . '<br> ok'; } else { //did not run ok echo $query .'<br> noob'; } }




Bookmarks