当我使用mysqli选择[关闭]时出错

<?php if($_POST) {  
$username = htmlspecialchars($_POST['username']);
$password = htmlspecialchars($_POST['password']);
$mysqli = new mysqli('localhost','root','','movie_posters');
$query = $mysqli->query("SELECT password FROM users WHERE username = '"$username"'");

} ?>

When I try this code on WAMP, I get error like; this http://i.stack.imgur.com/qcifR.jpg What can I do ?

Do not use single and double quotes in your query. This is the right way:

$query = $mysqli->query("SELECT password FROM users WHERE username = '$username'");

Otherwise, you will not print $username's value.

You have to put periods before and after you variable. In your example:

$query = $mysqli->query("SELECT password FROM users WHERE username = '".$username."'");