What is the significance of the error message "#1064 - You have an error in your SQL syntax" in PHP and MySQL?

The error message "#1064 - You have an error in your SQL syntax" in PHP and MySQL indicates that there is a syntax error in the SQL query being executed. This could be due to missing quotes, incorrect keyword usage, or other mistakes in the query. To solve this issue, carefully review the SQL query and correct any syntax errors present.

<?php
// Establish a connection to the database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";

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

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

// Correct the SQL query syntax
$sql = "SELECT * FROM users WHERE username = 'john'";

$result = $conn->query($sql);

if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
        echo "Username: " . $row["username"];
    }
} else {
    echo "0 results";
}

$conn->close();
?>