Home > Article > Backend Development > mysql_num_rows($result)总是等于0,为什么?解决方案
mysql_num_rows($result)总是等于0,为什么?急急
session_start();
$db=mysql_connect("localhost","root","205513")or die("unable to connect");
mysql_select_db("guanliku",$db)or die(mysql_error($db));
mysql_query("set names gb2312");
$name=(isset($_POST['name']))?trim($_POST['name']):'';
$password=(isset($_POST['passwrod']))?trim($_POST['password']):'';
$redirect=(isset($_REQUEST['redirect']))?$_REQUEST['redirect']:'tobiao.php';
if(isset($_POST['submit'])&&$_POST['submit']=='Login'){
$query='select access_level from cms_users
where '.'name="'.mysql_real_escape_string($name,$db).'"and
'.'password=PASSWORD("'.mysql_real_escape_string($password,$db).'")';
$result=mysql_query($query,$db)or die(mysql_error($db));
if(mysql_num_rows($result)>0){
$_SESSION['name']=$name;
$_SESSION['logged']=1;
header('Refresh: 5; URL='.$redirect);
echo '
'.$name.'你将进入你自己的主页!
'; 不合法的用户名'.
'密码! 请 点击'.'注册 如果你还没有注册