我做了2文件的PHP:你能解釋一下這個錯誤信息嗎?
- class.datebase.php
- class.ManageDatabase.php
這個文件我用來連接到數據庫......但我得到的錯誤。 ..
你能幫助我..
class.database.php:
<?php
include_once ('../config.php');
class database {
protected $db_conn;
public $db_name = DB_NAME;
public $db_host = DB_HOST;
public $db_user = DB_USER;
public $db_pass = DB_PASS;
}
function connect(){
try {
$this->db_conn = new PDO("mysql:host = $this->db_host;dbname=$this->db_name",$this->db_user,$this->db_pass);
return $this->db_conn;
} catch(PDOException $e) {
return $e->getMessage();
}
}
?>
class.ManageDatabase.php:
<?php
class ManageDatabase{
public $link;
function __construct(){
include_once('class.database.php');
$conn = new database;
$this->link = $conn->connect();
return $this->link;
}
}
$something = new ManageDatabase;
echo $something;
?>
和錯誤:
Fatal error: Call to undefined method database::connect() in C:\xampp\htdocs\myweb\crud\core\class.ManageDatabase.php on line 9
連接()不是類數據庫中的一員。 – erenon
謝謝你的...... 我是多麼傻啊:) – user2467583