What are the potential issues with using mysql_query in PHP and why should it be avoided?

Using `mysql_query` in PHP is not recommended as it is deprecated and has been removed in newer versions of PHP. It is also prone to SQL injection attacks if user input is not properly sanitized. Instead, it is recommended to use prepared statements with PDO or MySQLi for database queries in PHP.

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

// Prepare a statement
$stmt = $pdo->prepare('SELECT * FROM table_name WHERE column_name = :value');

// Bind parameters and execute
$stmt->bindParam(':value', $value);
$stmt->execute();

// Fetch results
$results = $stmt->fetchAll();