What are the potential pitfalls of using a simple counter with reload/IP-sperre based on MySQL for tracking website traffic?

Potential pitfalls of using a simple counter with reload/IP-sperre based on MySQL for tracking website traffic include scalability issues as the database can become overwhelmed with frequent updates, potential for inaccurate data due to multiple users accessing the site from the same IP address, and vulnerability to SQL injection attacks if proper input validation is not implemented.

<?php
// Connect to MySQL database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "website_traffic";

$conn = new mysqli($servername, $username, $password, $dbname);

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

// Get visitor's IP address
$ip_address = $_SERVER['REMOTE_ADDR'];

// Check if IP address is already in database
$sql = "SELECT * FROM visitor_counts WHERE ip_address = '$ip_address'";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // IP address already exists, do not increment counter
    echo "Visitor count already recorded for this IP address.";
} else {
    // IP address does not exist in database, increment counter
    $sql = "INSERT INTO visitor_counts (ip_address) VALUES ('$ip_address')";
    if ($conn->query($sql) === TRUE) {
        echo "Visitor count incremented.";
    } else {
        echo "Error: " . $sql . "<br>" . $conn->error;
    }
}

$conn->close();
?>