Error ครับพี่
Warning: mssql_query(): supplied argument is not a valid MS SQL-Link resource in C:\AppServ\www\CC\detail_add.php on line 13
Warning: mssql_fetch_assoc(): supplied argument is not a valid MS SQL-result resource in C:\AppServ\www\CC\detail_add.php on line 14
Code (PHP)
$strSQL = "SELECT * FROM detail";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
$strSQL ="INSERT INTO detail";
$strSQL .="(ThaiName)";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["text_name"]."') ";
$strSQL = "SELECT @@IDENTITY AS last_id;";
$objQuery = mssql_query($strSQL, $your_link_identifier);
$rows = mssql_fetch_assoc($result);
$last_id = $rows["last_id"];
$strSQL = "SELECT * FROM tel";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
$strSQL ="INSERT INTO tel";
$strSQL .="(tel,ThaiName,id_detail)";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["text_tel"]."','".$_POST["text_name"]."','".$_POST["text_id_detail"]."') ";
$objQuery = mssql_query($strSQL);
Date :
2011-07-26 00:00:31
By :
w
No. 16
Guest
มันไป errorอีกทีที่
Warning: mssql_query() [function.mssql-query]: message: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_tel_detail". The conflict occurred in database "cc1799", table "dbo.detail", column 'id_detail'. (severity 16) in C:\AppServ\www\CC\detail_add.php on line 23
Warning: mssql_query() [function.mssql-query]: Query failed in C:\AppServ\www\CC\detail_add.php on line 23
Code (PHP)
$strSQL = "SELECT * FROM detail";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
$strSQL ="INSERT INTO detail";
$strSQL .="(ThaiName)";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["text_name"]."') ";
$strSQL = "SELECT @@IDENTITY AS last_id;";
$objQuery = mssql_query($strSQL); //ลองแก้-------------------------------------------------------------------------------
$rows = mssql_fetch_assoc($objQuery); //ลองแก้-------------------------------------------------------------------------
$last_id = $rows["last_id"];
$strSQL = "SELECT * FROM tel";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
$strSQL ="INSERT INTO tel";
$strSQL .="(tel,ThaiName,id_detail)";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["text_tel"]."','".$_POST["text_name"]."','".$_POST["text_id_detail"]."') ";
$objQuery = mssql_query($strSQL);//บรรทัดที่ฟ้อง error-------------------------------------------------------------------