Warum fehlen die Hochkommatas um die Variable $username in der Abfrage?

The reason the single quotes are missing around the variable $username in the query is because PHP does not interpolate variables inside single quotes. To fix this issue, you need to concatenate the variable with the rest of the query using the dot (.) operator.

// Incorrect query without single quotes around $username
$query = "SELECT * FROM users WHERE username = $username";

// Corrected query with single quotes around $username
$query = "SELECT * FROM users WHERE username = '" . $username . "'";