php 求救,我的程序出错了!
<?session_start();classchklogin{private$username;private$pass;private$xym;publicfunct...
<?
session_start();
class chklogin
{
private $username;
private $pass;
private $xym;
public function __contruct($username,$pass,$xym){
$this->username=$username;
$this->pass=$pass;
$this->xym=$xym;
}
public function chk(){
include_once("conn.php");
$sql=mysql_query ('select username from admin where usermane=".$this->username. " and pass=".$this->pass."',$conn );
$info1=mysql_fetch_array("$sql") ;
if($info1==false){
echo "<script> alert('用户名或密码错误!');window.history.back();</script>";
exit;
}
if (trim ($this->xym )!==trim($_session ["autonum"])){
echo "<script >alert ('效验码错误!');window.history.back();</script >";
exit;
}
if($_SESSION["username"]!=""){
session_unregister("username");
} else {
session_register("username");
$_SESSION["username"]=$this->username ;
// mysql_query("update admin set logintimes =logintimes+1,lasttimes ='".date ("Y-m-d H:i:s")."'",$conn);
echo "<script> alert('登陆成功!'); window.location.href='index0.php';</script>" ;
}
}
}
$obj=new chklogin($_POST[username],md5($_POST[pass]),$_POST[xym]) ;
$obj->chk();
?>
但是提示错误 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in F:\AppServ\www\test\test0.php on line 26
请高手帮帮我!! 展开
session_start();
class chklogin
{
private $username;
private $pass;
private $xym;
public function __contruct($username,$pass,$xym){
$this->username=$username;
$this->pass=$pass;
$this->xym=$xym;
}
public function chk(){
include_once("conn.php");
$sql=mysql_query ('select username from admin where usermane=".$this->username. " and pass=".$this->pass."',$conn );
$info1=mysql_fetch_array("$sql") ;
if($info1==false){
echo "<script> alert('用户名或密码错误!');window.history.back();</script>";
exit;
}
if (trim ($this->xym )!==trim($_session ["autonum"])){
echo "<script >alert ('效验码错误!');window.history.back();</script >";
exit;
}
if($_SESSION["username"]!=""){
session_unregister("username");
} else {
session_register("username");
$_SESSION["username"]=$this->username ;
// mysql_query("update admin set logintimes =logintimes+1,lasttimes ='".date ("Y-m-d H:i:s")."'",$conn);
echo "<script> alert('登陆成功!'); window.location.href='index0.php';</script>" ;
}
}
}
$obj=new chklogin($_POST[username],md5($_POST[pass]),$_POST[xym]) ;
$obj->chk();
?>
但是提示错误 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in F:\AppServ\www\test\test0.php on line 26
请高手帮帮我!! 展开
2个回答
展开全部
下次提问的时候,在最后把26行贴出来,或者在文件里面标明“这里就是26行”,别人数起来很麻烦的~
下面的语句有错:
$sql=mysql_query ('select username from admin where usermane=".$this->username. " and pass=".$this->pass."',$conn );
应该修改为:
$sql=mysql_query ('select username from admin where usermane="'.$this->username.'" and pass="'.$this->pass.'"',$conn );
仔细看,你丢失了几个单引号。
不知道是否其它地方还有错,你修改后运行一下看
下面的语句有错:
$sql=mysql_query ('select username from admin where usermane=".$this->username. " and pass=".$this->pass."',$conn );
应该修改为:
$sql=mysql_query ('select username from admin where usermane="'.$this->username.'" and pass="'.$this->pass.'"',$conn );
仔细看,你丢失了几个单引号。
不知道是否其它地方还有错,你修改后运行一下看
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
数据库连接资源$conn 是个无效的
你把这行
include_once("conn.php");
放在文件开始处
<?
include_once("conn.php");
session_start();
语法有点错误:
$sql=mysql_query ("select username from admin where usermane='".$this->username. "' and pass='".$this->pass."'",$conn );
$info1=mysql_fetch_array($sql) ;
你把这行
include_once("conn.php");
放在文件开始处
<?
include_once("conn.php");
session_start();
语法有点错误:
$sql=mysql_query ("select username from admin where usermane='".$this->username. "' and pass='".$this->pass."'",$conn );
$info1=mysql_fetch_array($sql) ;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询