 |
ช่วยดูปัญหาการ INSERT ข้อมูล mssql_query แล้ว error "mssql_query(): supplied argument is not a valid MS SQL-Link resource in C:\AppServ\...." |
|
 |
|
|
 |
 |
|
Code (PHP)
function connectdb($db_name="database",$user="username",$pwd="password"){
$this->database = $db_name;
$this->username = $user;
$this->password = $pwd;
$this->connect_db = mssql_connect ( $this->host, $this->username, $this->password ) or $this->_error();
//$this->connect_db = mysql_pconnect ( $this->host, $this->username, $this->password ) or $this->_error();
$this->db = mssql_select_db ( $this->database, $this->connect_db) or $this->_error();
//mssql_query("SET NAMES TIS620");
//mssql_query("SET character_set_results=UTF8");
return true;
}
$db->connectdb("erathai","sa","1234");
$sql = "INSERT INTO tm_customer (Cuscode,Note) VALUES ('$_POST[CusCode]','test') ";
$objQuery = mssql_query($sql,$db);
if($objQuery){
echo "Save Done.";
}else{
echo "Error Save [".$sql."]";
}
ERROR
Warning: mssql_query(): supplied argument is not a valid MS SQL-Link resource in C:\AppServ\www\erathai\bof\modules\php_pro\add.php on line 114
Error Save [INSERT INTO tm_customer (Cuscode,Note) VALUES ('C00001','test') ]
Tag : PHP, Ms SQL Server 2008, CakePHP, WebService
|
|
 |
 |
 |
 |
Date :
2012-01-12 11:59:54 |
By :
golderboy |
View :
1885 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
INSERT INTO tm_customer (Cuscode,Note) VALUES ('$_POST[CusCode]','test')
คุณลองเอาตัวนี้ ไป test ใน phpmyadmin ก่อนครับ เปลี่ยนตัวแปร $_POST[CusCode] เป็นอะไรก็ได้ก่อนแล้ว
เทสดูว่าลงใน ฐานข้อมูลไหมครับ ถ้าลงก็หาฟังชัน ใหม่เลยครับ หรือจะแก้เองก็"ด้ ^^
|
 |
 |
 |
 |
Date :
2012-01-12 12:04:55 |
By :
หาของ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมใช้ SQL Server ครับ ไม่ใช่ MySql
|
 |
 |
 |
 |
Date :
2012-01-12 12:16:17 |
By :
golderboy |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
not a valid MS SQL-Link resource แปลว่า ยังไม่มีการ connect database ดูดีๆ เขียน function หรือ class ก็ต้องใช้มันให้จบกระบวนการ
|
 |
 |
 |
 |
Date :
2012-01-12 12:33:10 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ครับ ดูแล้วน่าจะมีปัญหาตั้งแต่การ connect ครับ 
|
 |
 |
 |
 |
Date :
2012-01-12 13:14:03 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|