What are some potential pitfalls when using PHP to edit entries in a database?

One potential pitfall when using PHP to edit entries in a database is SQL injection attacks. To prevent this, you should always use prepared statements with parameterized queries to sanitize user input and prevent malicious SQL code from being executed.

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

// Prepare a SQL statement with placeholders
$stmt = $pdo->prepare("UPDATE users SET username = :username WHERE id = :id");

// Bind parameters
$stmt->bindParam(':username', $_POST['username']);
$stmt->bindParam(':id', $_POST['id']);

// Execute the statement
$stmt->execute();