PHP 连接mysql的有关问题 新手!

WBOY
Lepaskan: 2016-06-13 12:45:26
asal
754 orang telah melayarinya

PHP 连接mysql的问题 新手!!!

本帖最后由 zuoan2008 于 2013-06-25 16:38:28 编辑 我的login_action.php
<br />
 <?php<br />
	include('../config/config_db.php');<br />
	include('../class/db/class_db.php');<br />
	<br />
<br />
<br />
	$username= $_POST["username"];<br />
	$password=$_POST["password"];<br />
    <br />
	echo "username:".$username."--"."password:".$password."</br>";<br />
    echo "db_host:".$db_host."--"."db_name:".$db_name."--"."db_pass:".$db_pass."--"."db_dabase:".$db_dabase;<br />
	$mysqldb==new MySQLDB($db_host,$db_name,$db_pass,$db_dabase);<br />
    <br />
	 <br />
    <br />
	$sql = "select * from loginuser where username='".$username."'";<br />
    $result = $mysqldb->Query($sql);//查询<br />
    $rs = $mysqldb->getRows($result);//获得记录集<br />
    $num = $mysqldb->getRowsNum($result);//获得记录数<br />
<br />
	if($num>0){<br />
		//如果是 登陆<br />
		session_start();<br />
		$_SESSION['username']=$username;<br />
        $_SESSION['password']=$password;<br />
		echo "<script>location.href='index.php';</script>";<br />
	}else{<br />
		echo "登录错误";<br />
	}<br />
?><br />
Salin selepas log masuk


config_db.php
<br />
<?php<br />
<br />
$db_host = 'localhost';<br />
$db_name = 'root';<br />
$db_pass = '123456';<br />
$db_dabase = 'test';<br />
$db_ut = 'utf8';<br />
<br />
?><br />
Salin selepas log masuk


class_db.php
<br />
 <?php<br />
Class MySQLDB<br />
{<br />
		var $host;<br />
		var $user;<br />
		var $passwd;<br />
		var $database;<br />
		var $conn;<br />
<br />
		//利用构造函数实现变量初始化<br />
		//同时连接数据库操作<br />
		function MySQLDB($host,$user,$password,$database)<br />
		{<br />
			$this->host = $host;<br />
			$this->user = $user;<br />
			$this->passwd = $password;<br />
			$this->database = $database;<br />
			$this->conn=mysql_connect($this->host, $this->user,$this->passwd) or die("Could not connect to $this->host");<br />
			mysql_select_db($this->database,$this->conn) or die("Could not switch to database $this->database");<br />
			mysql_query("set names 'gbk'");<br />
		}<br />
<br />
		//该函数用来关闭数据库连接<br />
		function Close()<br />
		{<br />
		    MySQL_close($this->conn);<br />
		}<br />
<br />
		//该函数实现数据库查询操作<br />
		function Query($queryStr)<br />
		{<br />
		   $res =Mysql_query($queryStr, $this->conn) or die("Could not query database");<br />
		   return $res;<br />
		}<br />
<br />
<br />
} <br />
Salin selepas log masuk



错误提示:Fatal error: Call to a member function Query() on a non-object in D:\AppServ\www\jxc\include\action\login_action.php on line 17

也就是login_action.php里面的    $result = $mysqldb->Query($sql);//查询  
这一行
 
请问大侠们怎么解决?  谢谢!
Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan