I have a very peculiar bug here. Classes and such are trunc'd for readability.
SHORT DESC: Posting a value to field nationality
changes the field from 0 to 1 and vice versa WHILE changing the value of the next field to the first character that was put in by the user in the nationality field. If repeated (form resubmission with different input upd8ing the user entry), the first letter gets shifted to the next field while the newly put in first letter of the nationality field is the former field. THis goes three fields deep, after that there are no more "ghost changes".
Long Description:
What I have: I have a table 'user' in a Mysql 5.1.61 (client) and 5.5.28-log(srvr) environment.
That table used to contain, amongst others those fields:
{birthdate, gender, phone, mobile}
I added a field before gender using the qry {ALTER TABLE 'user' ADD 'nationality' varchar(40) AFTER 'birthdate'}
resulting in
{birthdate, nationality, gender, phone, mobile}
I feed the table with data from a form that posts these values:
if ($resp->is_valid) {
registerNewUser($_POST['email'],$_POST['name'],$_POST['firstname'], $_POST['password']);
updateCurrentUser($_POST['email'], $_POST['name'], $_POST['firstname'], $_POST['date_of_birth'], $_POST['nationality'], $_POST['gender'], $_POST['telephone'], $_POST['mobile']);
updateCurrentUser
looks like this:
function &updateCurrentUser($email, $name, $firstname, $street, $city, $postalCode, $DateOfBirth, $nationality, $gender, , $telephone, $mobile, $hasRoomForRent, $isIaesteMember, $hasMadeTraineeship, $password, $dataApproved){
$dbh = getPDO();
$stmt = $dbh->prepare('UPDATE user SET name = :name, first_name = :firstname, street = :street, city = :city, postal_code = :postalCode, date_of_birth = :dateOfBirth, nationality = :nationality, gender = :gender, telephone = :telephone, mobile = :mobile, hasRoomForRent = :hasRoomForRent, isIaesteMember = :isIaesteMember, hasMadeTraineeship = :hasMadeTraineeship, dataIsApproved = :dataIsApproved '.((isset($password) && $password != 'password')? ',password = :password': '').' WHERE email = :email');
$stmt->bindParam(':dateOfBirth', $DateOfBirth);
$stmt->bindParam(':nationality', $nationality);
$stmt->bindParam(':gender', $gender);
$stmt->bindParam(':telephone', $telephone);
$stmt->bindParam(':mobile', $mobile);
THis is the user class
class User {
private $email;
private $firstname;
private $name;
private $street;
private $city;
private $postalCode;
private $dateOfBirth;
private $nationality;
private $gender;
private $telephone;
private $mobile;
...
public function getNationality() {
return $this->nationality
...;
I genuinely dont know what is going on. The order of the fields seems to stack up what is the issue ?
You specified the arguments $street, $city, $postalCode before $DateOfBirth so in your function what you may have been referencing as $DateofBirth may end up being the telephone number, etc.
I think you should check your insert or update queries ensuring all parameters are inserted the way they exist in the table structure if your table contains feilds in the order // { birthdate,nationality,gender,phone,mobile} then insert query should be insert into tablename values('01-10-1991','indian','m','6667669','67686767'); also check the data types before inserting