$password=$_POST['password']; $conn=mysql_connect ("localhost","root","2295371c."); if ( !$conn) { die ("连接失败!".mysql_errno()); } mysql_query ("set names utf8",$conn) or die ("编码格式错误!".mysql_errno()); mysql_select_db("demodb",$conn) or die ("连接数据库错误!".mysql_errno()); $sql="select password from users where username=$username"; $res=mysql_query($sql,$conn); if ($row=mysql_fetch_assoc($res)){ if ($row=['password']==md5($password)){ header ("location:123.php"); exit(); } }// header ("location: fail.php"); exit(); mysql_free_result($res); mysql_close($conn);?>
数据库表中的内容:
var_dump($sql);在页面中显示的是:string(49) "select password from users where username=changgy"
var_dump($res);在页面中显示的是:bool(false) 为什么会这样呢?PHP怎么不执行sql语句呢?请大侠指点。
展开