$query="select * from yonghu_t where yonghu_yhmc='$username'";$result=mysql_query($query);$result_u=mysql_fetch_row($result);
echo $query;
echo mysql_num_rows($result);mysql_num_rows($result)返回的总是0,数据库有或者没有返回的都是0 为什么啊 ?
echo $query;
echo mysql_num_rows($result);mysql_num_rows($result)返回的总是0,数据库有或者没有返回的都是0 为什么啊 ?
<?php
include '../db/conn.php';
$username=$_REQUEST['username'];
$password=$_REQUEST['password'];$query="select * from yonghu_t where yonghu_yhmc='$username'";$result=mysql_query($query);
$rows=mysql_num_rows($result);
//$result_u=mysql_fetch_row($result);
if($rows){
if($password==$result_u[1]){
session_start();
$_SESSION['username']=$username;
echo "<script>";
echo "window.location.href='../main.html'";
echo "</script>"; }else{
echo "<script>";
echo "alert('密码或者账号错误');";
echo "window.location.href='../index.php'";
echo "</script>";
}
}
else{
echo "<script>";
echo "alert('用户名不存在');";
echo "window.location.href='../index.php'";
echo "</script>";
}?>
$query="select * from yonghu_t where yonghu_yhmc='$username'"; $result=mysql_query($query); $result_u=mysql_fetch_row($result);
print_r($result_u); //打印出来看一下
//echo $query; //echo mysql_num_rows($result);
确定一下SQL语句是否有问题
$result_u=mysql_fetch_row($result);
echo $result_u[0];
就这句代码
$result_u[0]什么都没有;