Your ON DUPLICATE KEY syntax is incorrect.
$stmt = $conn->prepare('INSERT INTO customer_info (user_id, fname, lname) VALUES(:user_id, :fname, :lname) ON DUPLICATE KEY UPDATE fname= :fname2, lname= :lname2'); $stmt->bindParam(':user_id', $user_id); $stmt->bindParam(':fname', $_POST['fname'], PDO::PARAM_STR); $stmt->bindParam(':lname', $_POST['lname'], PDO::PARAM_STR); $stmt->bindParam(':fname2', $_POST['fname'], PDO::PARAM_STR); $stmt->bindParam(':lname2', $_POST['lname'], PDO::PARAM_STR);
You do not need to specify the table name or SET in the ON DUPLICATE KEY , and you do not need the WHERE (it always updates the record with a duplicate key).
See http://dev.mysql.com/doc/refman/5.5/en/insert-on-duplicate.html
You also had a PHP syntax error: you split the request into two lines.
UPDATE:
To link several parameters:
function bindMultiple($stmt, $params, &$variable, $type) { foreach ($params as $param) { $stmt->bindParam($param, $variable, $type); } }
Then call it:
bindMultiple($stmt, array(':fname', ':fname2'), $_POST['fname'], PDO::PARAM_STR);