时间:2021-07-01 10:21:17 帮助过:8人阅读
"; echo "db_host:".$db_host."--"."db_name:".$db_name."--"."db_pass:".$db_pass."--"."db_dabase:".$db_dabase; $mysqldb==new MySQLDB($db_host,$db_name,$db_pass,$db_dabase); $sql = "select * from loginuser where username='".$username."'"; $result = $mysqldb->Query($sql);//查询 $rs = $mysqldb->getRows($result);//获得记录集 $num = $mysqldb->getRowsNum($result);//获得记录数 if($num>0){ //如果是 登陆 session_start(); $_SESSION['username']=$username; $_SESSION['password']=$password; echo ""; }else{ echo "登录错误"; }?>
host = $host; $this->user = $user; $this->passwd = $password; $this->database = $database; $this->conn=mysql_connect($this->host, $this->user,$this->passwd) or die("Could not connect to $this->host"); mysql_select_db($this->database,$this->conn) or die("Could not switch to database $this->database"); mysql_query("set names 'gbk'"); } //该函数用来关闭数据库连接 function Close() { MySQL_close($this->conn); } //该函数实现数据库查询操作 function Query($queryStr) { $res =Mysql_query($queryStr, $this->conn) or die("Could not query database"); return $res; }}
$mysqldb =new MySQLDB($db_host,$db_name,$db_pass,$db_dabase);