What is the potential issue with using the mysql_query function in PHP?

The potential issue with using the mysql_query function in PHP is that it is deprecated as of PHP 5.5.0 and removed in PHP 7.0.0. This function is no longer recommended for use due to security vulnerabilities and lack of support for newer versions of MySQL. To solve this issue, it is recommended to use MySQLi or PDO extensions for database operations in PHP.

// Connect to database using MySQLi
$mysqli = new mysqli("localhost", "username", "password", "database");

// Check connection
if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
}

// Perform query using prepared statement
$query = "SELECT * FROM table_name";
$stmt = $mysqli->prepare($query);
$stmt->execute();
$result = $stmt->get_result();

// Fetch data
while ($row = $result->fetch_assoc()) {
    // Process data here
}

// Close connection
$stmt->close();
$mysqli->close();