I\'m trying to create a page that allows users change their info in a sql database using PDO. I\'m new to this and I\'m running into an error. I\'m using this as a source: http:
I have simplified the code to illustrate how to create dynamic UPDATE query. This uses "lazy" binding and regular placeholders ?
.
The text inputs are set as a regular array (ie. not associative) of values.
";
print_r($query_params);
// Execute the query
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
}
}
?>
Typical result
UPDATE `users` SET `info1` = ?,`info2` = ? WHERE `id` = ?
Array ( [0] => john [1] => smith [2] => johnsmith )