|
 |
|
PHP and MySQL ดูให้หน่อยครับมันไม่โชว์อะไรเลย....... |
|
 |
|
|
 |
 |
|
connect DB ยังอะคับ
|
 |
 |
 |
 |
Date :
2012-07-23 16:21:39 |
By :
Krungsri |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$result=mysql_query($sql) or die(mysql_error());
เอา error มาดูหน่อยครับ
|
 |
 |
 |
 |
Date :
2012-07-23 16:32:14 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
No database selected = ไม่มีฐานข้อมูลครับ
ขอเช็คโค๊ด mysql_connect กับ mysql_select_db ดูครับ หรือไม่งั้น ขอดูโค๊ดหน่อยครับ
|
 |
 |
 |
 |
Date :
2012-07-23 16:44:33 |
By :
Ex-[S]i[L]e[N]t |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ชื่อ DB อาจจะไม่ตรงกันลองดูไหม นะครับ
|
 |
 |
 |
 |
Date :
2012-07-24 09:56:45 |
By :
a-rin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตรงแล้วนะครับ
|
 |
 |
 |
 |
Date :
2012-07-24 10:09:16 |
By :
l3alLkisS |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ที่ไฟล์ไว้สำหรับ connect ฐานข้อมูล ชื่อ db ว่าอะไรครับ มันตรงกับ db ที่สร้างขึ้นใหม่หรือเปล่า ตรวจสอบดีดี 
เอา CODE มาดูเลยดีกว่า
|
ประวัติการแก้ไข 2012-07-24 10:18:26
 |
 |
 |
 |
Date :
2012-07-24 10:13:39 |
By :
apisitp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอดู Code เลยละกันครับ พร้อมรายละเอียด ชื่อฐานข้อมูล เดี๋ยเช็คให้ครับ
|
 |
 |
 |
 |
Date :
2012-07-24 10:16:20 |
By :
Ex-[S]i[L]e[N]t |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อันนี้คือไฟล์ database
Code (PHP)
<?php
require("Settings_PHP.php");
require("ResultSet.php");
class Database {
private $connection;
static $instances = 0;
private $hostname;
private $databasename;
private $username;
private $password;
private $table;
private $duptable;
function __construct($db_id = "db0") {
$settings = new Settings_PHP();
$settings->load($_SERVER["DOCUMENT_ROOT"]."/2012/config.php");
$this->hostname = $settings->get($db_id.".hostname");
$this->databasename = $settings->get($db_id.".database");
$this->username = $settings->get($db_id.".username");
$this->password = $settings->get($db_id.".password");
if(Database::$instances == 0) {
$this->connection = mysql_connect($this->hostname,$this->username,$this->password) or die(mysql_error(). " Error no:".mysql_errno());
mysql_query("SET NAMES TIS620");
Database::$instances = 1;
}
else {
$msg = "Close the existing instance of the Database class.";
die($msg);
}
}
function __destruct() {
$this->close();
}
function getConnection() {
return $this->connection;
}
function getResultSet($sql) {
$rs = new ResultSet($sql, $this->databasename, $this->connection);
return $rs;
}
function execCommand($sql) {
mysql_db_query($this->databasename, $sql) or die(mysql_error(). " Error no:".mysql_errno());
}
function getInsertID() {
return mysql_insert_id();
}
function getEffectRow() {
return mysql_affected_rows();
}
function export($table, $duptable) {
$this->table = $table;
$this->duptable = $duptable;
$header = $this->create_header();
return($header);
}
private function create_header() {
$fields = mysql_list_fields($this->databasename, $this->table, $this->connection);
$h = "CREATE TABLE `" . $this->duptable . "` (";
$pkey = "";
$rs = mysql_query("SHOW FIELDS FROM ".$this->table);
while($row = mysql_fetch_assoc($rs)) {
$name = $row["Field"];
$type = $row["Type"];
$null = $row["Null"];
$key = $row["Key"];
$default = $row["Default"];
$extra = $row["Extra"];
$h .= "`".$name."` ".$type." ".($null == "NO" ? "NOT NULL" : "NULL")." ".$extra.",";
if($key == "PRI") {
$pkey .= ",PRIMARY KEY (`".$name."`)";
}
if($key == "MUL") {
$pkey .= ",`".$name."` (`".$name."`)";
}
}
$h = substr($h, 0, strlen($h) - 1);
$h .= $pkey.") TYPE=MyISAM DEFAULT CHARSET=tis620;";
return($h);
}
function close() {
Database::$instances = 0;
if(isset($this->connection)) {
mysql_close($this->connection);
unset($this->connection);
}
}
}
?>
ส่วนอันนี้คือไฟล์ configCode (PHP)
<?php
$db0 = array();
$db0["hostname"] = "localhost";
$db0["database"] = "test";
$db0["username"] = "root";
$db0["password"] = "1234";
$mail = array();
$mail["smtp"] = "202.57.128.202";
$mail["port"] = 25;
?>
ส่วน database ก็ชื่อ test นะครับ
|
 |
 |
 |
 |
Date :
2012-07-24 10:19:31 |
By :
l3alLkisS |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|