我在我db.php中這種語法是錯誤的嗎?
define("DB_USER","root");
define("DB_PASSWORD","");
define("DB_DB","exotic_live");
define("DB_HOST", "localhost");
定義此拋出一個錯誤
Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in C:\xampp\htdocs\test\config\db.php on line 5
完整的代碼是
class Database{
//define('DB_HOST','localhost');
define("DB_USER","root");
define("DB_PASSWORD","");
define("DB_DB","exotic_live");
define("DB_HOST", "localhost");
private function db_connect(){
$this->dbconnect();
}
private function dbconnect() {
$conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD)
or die ("<br/>Could not connect to MySQL server");
mysql_select_db(DB_DB,$conn)
or die ("<br/>Could not select the indicated database");
return $conn;
}
}
$obj_db=new Database();
$obj_db->db_connect();
本來準備下一次我得到了一個無法解釋留下一個笑話評論downvote,但即使我不認爲這將是有趣的了。猜猜我會保存它元或什麼的。 * -shrug- * – BoltClock 2011-06-06 09:47:09
(這不是笑話評論,順便說一句) – BoltClock 2011-06-06 09:54:14
@BoltClock,這是使db文件像這樣的最佳做法?。任何安全的方式? – user439555 2011-06-06 10:02:36