<?php
include_once(ROOTS.'/../libs/adodb/adodb.inc.php');class DataBase{
private $conn;
//析构函数
function __construct($db_type,$db_debug,$db_host,$db_user,$db_pswd,$db_base){

$this->conn=ADONewConnection($db_type);
$this->conn->debug=$db_debug;
$this->conn->PConnect($db_host,$db_user,$db_pswd,$db_base);

}

//取行数传统方式
function GetCounts($dbtables){
$sql="select count(*) from $dbtables";
$rs=$this->conn->Execute($sql);
$nums=$rs->fields[0];
return $nums;
}
}?><?php
$user=filter("username");
$pswd=filter("userpass");session_start();
$dbcharset = 'utf8';
$db_type='mysql';
$db_debug=true;
$db_host='localhost';
$db_user='root';
$db_pswd='123';
$db_base='php_games';//生成adodb的对象$db=new DataBase($db_type,$db_debug,$db_host,$db_user,$db_pswd,$db_base);$sql="select * from php_admin where p_name='".$user."'";
$data_ary =$db->GetRow($sql); 
if ($data_ary == false) { 
echo "<script>location.href='login.php';</script>";
exit();
} else {  if(!($_SESSION["username"])){
$_SESSION["username"]=$data_ary['p_name']; 
}
//Header("Location: index.php");
echo "<script>location.href='../index.php';</script>";
exit();
//echo $data_ary['p_name'] . ' ' . $data_ary['p_pwd'] . ' ' . $data_ary['p_id'] . '<br>'; 

?>每次提示错误都是这一行:$data_ary =$db->GetRow($sql);Fatal error: Call to undefined method DataBase::GetRow() in C:\AppServ\www\daomu1\daomu\class\login.class.php on line 28请各位帮忙是那里得错误啊!谢谢!小弟在线等

解决方案 »

  1.   

    没有GetRow这个函数
    你为什么不直接用MySQL的扩展?
      

  2.   

    我用得是ADODB,没有用那些PHP得函数
      

  3.   

    没有这个方法嘛。GetRow, 自己试着在里面加一个吧!
      

  4.   

    $db=NewADOConnection('mysql'); //创建adodb对象,声明数据库类型为MySql
    $db->debug=true; //显示错误信息
    $db->Connect("localhost","root","123","php_games");// 连接数据库,user是我自己建的数据库名字$sql = "Select * FROM php_admin Where p_name='".$user."'"; $data_ary = $db->GetRow($sql); 但是为什么我这么写就可以运行呢,难道这个$db,和上面得那个$db不一样吗?