What are the potential security risks associated with user input in PHP scripts?

Potential security risks associated with user input in PHP scripts include SQL injection, cross-site scripting (XSS), and code injection attacks. To mitigate these risks, always validate and sanitize user input before using it in your scripts. Use prepared statements for database queries, escape special characters when outputting user input to prevent XSS attacks, and avoid using eval() or other functions that execute user input as code.

// Example of using prepared statements to prevent SQL injection
$stmt = $pdo->prepare('SELECT * FROM users WHERE username = :username');
$stmt->bindParam(':username', $_POST['username']);
$stmt->execute();
```
```php
// Example of escaping user input to prevent XSS attacks
echo htmlspecialchars($_POST['comment']);