 |
|
แบบนี้เค้าเรียกว่า Error Connect Databast หรือป่าวครับ ผิดตรงไหนช่วยติดหน่อยครับ พอดีไปดูคลิปของ " คุณ U " เลยเขียนตามพร้อมเปิดหนังสืออ่านไปด้วยเพื่อประกอบความเข้าใจ แต่ก็ยัง งง อยู่ดี 
Code
Warning: Missing argument 2 for Class_DB::__construct(), called in /Applications/XAMPP/xamppfiles/htdocs/Shirt/index.php on line 5 and defined in /Applications/XAMPP/xamppfiles/htdocs/Shirt/connect/class_db_inc.php on line 4
Warning: Missing argument 3 for Class_DB::__construct(), called in /Applications/XAMPP/xamppfiles/htdocs/Shirt/index.php on line 5 and defined in /Applications/XAMPP/xamppfiles/htdocs/Shirt/connect/class_db_inc.php on line 4
Warning: Missing argument 4 for Class_DB::__construct(), called in /Applications/XAMPP/xamppfiles/htdocs/Shirt/index.php on line 5 and defined in /Applications/XAMPP/xamppfiles/htdocs/Shirt/connect/class_db_inc.php on line 4
Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'DB_HOST,DB_ROOT,DB_PW,DB_NAME' (1) in /Applications/XAMPP/xamppfiles/htdocs/Shirt/connect/class_db_inc.php on line 6
Unknown MySQL server host 'DB_HOST,DB_ROOT,DB_PW,DB_NAME' (1)
ตัวอย่างโค๊ดครับ
config.inc.php
<?php
define("DB_HOST","localhost");
define("DB_ROOT","root");
define("DB_PW","");
define("DB_NAME","shirt");
?>
class_db.inc.php
<?php
class Class_DB
{
public function __construct($host,$user,$pass,$db_name)
{
mysql_connect($host,$user,$pass) or die (mysql_error());
mysql_select_db($db_name);
echo "connect";
}
}
?>
index.php
<?php
session_start();
include_once("connect/confing.inc.php");
include_once("connect/class_db_inc.php");
$db=new Class_DB("DB_HOST,DB_ROOT,DB_PW,DB_NAME");
?>
Tag : PHP, HTML/CSS
|
|
 |
 |
 |
 |
Date :
2012-05-08 00:35:44 |
By :
thethaicom |
View :
1196 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |