sql语句取不出来 若单输name=$username 可以取出 为什么啊

if(!$con) {
die ('Could not connect:'.mysql_error( ) );
}
mysql_select_db("user",$con);
$sql = "select name,password from usermsg where name='$username'";
//echo $sql;
$dbt=mysql_query($sql,$con);
//echo $dbt;
$num=mysql_num_rows($dbt);
echo $num;
if($num>0)
{
session_srart();
$_SESSION["login"]=true;
header("Location:favor.php");
exit;
}
else {
echo"<center><font color =red>登录失败!请检查用户名和密码!</font></center><br>";
}
}

$sql = "select name,password from usermsg where name='.$username.'";

echo $sql;

看看输出什么
温馨提示:答案为网友推荐,仅供参考
相似回答