Database error with bindingvalues

For a class assignment we were to make a form in which a user can log in, update account, and logout. It all works expect the update account changes arent bein saved in my SQL database and I keep getting a database error in my PHP. The error says it’s in my bound values, but i’ve looked and looked and they all appear to match. Please help me find the error.

[php]
try {

		$db = new PDO($dsn, $username, $password, $options);
		
		$update = "Update CustomerInfo set FirstName = :FirstName, LastName = :LastName, Address = :Address, City = :City, State= :State, Zip = :Zip, Phone = :Phone, EMail = :EMail, Password = :Password Where CustomerID = :CustomerID;";
		
		$SQL = $db->prepare($update);
		
		$SQL->bindValue(':CustomerID', $CustomerID);
		$SQL->bindValue(':FirstName', $FirstName);
		$SQL->bindValue(':LastName', $LastName);
		$SQL->bindValue(':Address', $Address);
		$SQL->bindValue(':City', $City);
		$SQL->bindValue(':State', $State);
		$SQL->bindValue(':Zip', $Zip);
		$SQL->bindValue(':Phone', $Phone);
		$SQL->bindValue(':EMail', $Email);
		$SQL->bindValue(':Password', $pword);		
		
		$SQL->execute();
			
		
	
} catch(PDOException $e) {
	echo("I blew up!");
	$errorMessage = $e-> getMessage();
	echo("<p>Database error: $errorMessage</p>");
}[/php]

It is very hard to debug without all the info. How did you create the table? Can you post a list of the fields in the table? The problem may be the ID. Did you set the CustomerID to be an ID field in the table? ID’s can not be
updated. They never changed. This might be your error.

First, you must look at your database field names and make sure they match your code’s versions.
I noticed you use caps on the names such as CustomerID. But, for Password, you have “pword”. So,
there may be a simple spelling error. Check those first.

Next, you must be writing the same values. This means that if you have created the fields so that the
CustomerID is a text field, you MUST write a text field to it. So, check where you are getting the info
for each field and make sure they match the database.

Lastly, show us the exact error message. Some errors are worded in a way that explains the problem.
If it says it is a bounded values error, that is a hint, but, the wording in the error may explain better.

Hope one of these solves it… Let us know if you can’t figure it out…

Sponsor our Newsletter | Privacy Policy | Terms of Service