Are there any potential issues or drawbacks with using mysql_query to count records in PHP?

Using `mysql_query` to count records in PHP is not recommended as it is deprecated and may lead to security vulnerabilities such as SQL injection. It is better to use prepared statements with parameterized queries to securely count records in a database.

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

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

// Prepare a statement to count records
$stmt = $mysqli->prepare("SELECT COUNT(*) FROM table_name");

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

// Bind the result
$stmt->bind_result($count);

// Fetch the result
$stmt->fetch();

// Output the count
echo "Total records: " . $count;

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