What are potential pitfalls when using Smarty with MySQL for output generation in PHP applications?

One potential pitfall when using Smarty with MySQL for output generation in PHP applications is the risk of SQL injection if user input is not properly sanitized. To prevent this, always use prepared statements or parameterized queries when interacting with the database.

// Example of using prepared statements with MySQL and Smarty
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = :username");
$stmt->bindParam(':username', $username);
$stmt->execute();
$users = $stmt->fetchAll();

$smarty->assign('users', $users);
$smarty->display('users.tpl');