What are the best practices for updating database records in PHP to avoid SQL injection vulnerabilities?

To prevent SQL injection vulnerabilities when updating database records in PHP, it is important to use prepared statements with bound parameters. This helps to separate SQL code from user input, making it impossible for malicious input to alter the SQL query.

// Connect to the database
$pdo = new PDO('mysql:host=localhost;dbname=mydatabase', 'username', 'password');

// Update database records using prepared statements
$stmt = $pdo->prepare("UPDATE table SET column = :value WHERE id = :id");
$stmt->bindParam(':value', $value);
$stmt->bindParam(':id', $id);
$stmt->execute();