since $username is a php variable we need to pass it as string to mysqli so since in the query u started with a single quote we will use the double quote, single quote and a fullstop for the concatination purposes ("'.$username.'") if you started with a double quote you would then reverse the quotes ('".$username."').
$username = $_POST['username'];
$password = $_POST['password'];
$result = mysql_query('SELECT * FROM Users WHERE UserName LIKE "'.$username.'"');
while($row = mysql_fetch_array($result))
{
echo $row['FirstName'];
}
$username = $_POST['username'];
$password = $_POST['password'];
$result = mysql_query("SELECT * FROM Users WHERE UserName LIKE '".$username."' ");
while($row = mysql_fetch_array($result))
{
echo $row['FirstName'];
}
but use of Mysql has depreciated much, use PDO instead.it is simple but very secure
mysql_real_escape_string. Never trust user data.mysql_real_escape_stringis not the be-all and end-all of SQL injection protection; it's still vulnerable to a number of attacks. (No, you never said it's perfect, but you implied it was the only required solution) The best solution now is PDO, as far as I know.