I can not for the life of me figure out how to format this for it to work properly.
I am running a query on a database, and it works completely fine if you put in a string of the username directly.
$link = mysqli_connect("localhost", "root", "123", "accounts");
$query = "SELECT balance FROM `users` WHERE `username` = 'bob'";
$result = mysqli_query($link, $query);
$row = mysqli_fetch_row($result);
return $row[0];
However, if I replace the query with
$query = "SELECT balance FROM `users` WHERE `username` = $username";
It will not work. I've tried every combination I can try for the variable $username, and it still doesn't work. Can someone guide me in the right direction?