 |
ERROR ตอนบันทึกค่าลงฐานข้อมูลครับ Warning: mssql_query() [function.mssql-query]: |
|
 |
|
|
 |
 |
|
เป็นการบันทึกข้อมูลจากการ upload excel ครับ ผม insert พร้อมกัน 2 ตาราง
Code
Warning: mssql_query() [function.mssql-query]: message: There are more columns in the INSERT statement than values
specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in
the INSERT statement. (severity 15) in D:\testexcle\PHPExcel\ExtendProjectSQL.php on line 86
Warning: mssql_query() [function.mssql-query]: Query failed in D:\testexcle\PHPExcel\ExtendProjectSQL.php on line 86
INSERT INTO pis_discount (cust_code,Project_Name,business_type,pj_nr,cash,periodDate_from,periodDate_to,Align)
VALUES ('5305689','อาคารพาณิชย์&ทาวน์โฮม','AG' ,'PJ','CH','' ,'')
Row A 1 Inserted...
Warning: mssql_query() [function.mssql-query]: message: Error converting data type varchar to numeric. (severity 16) in
D:\testexcle\PHPExcel\ExtendProjectSQL.php on line 97
Warning: mssql_query() [function.mssql-query]: Query failed in D:\testexcle\PHPExcel\ExtendProjectSQL.php on line 97
INSERT INTO pis_discountMat (material_code,off_invoice,rebate,rebate_2,rebate_3,total,Quota) VALUES ('81100010','350',''
,'625','','975' ,'300')
Row B 1 Inserted...
Code (PHP)
$strSQL = "";
$strSQL .= "INSERT INTO pis_discount ";
$strSQL .= "(cust_code,Project_Name,business_type,pj_nr,cash,periodDate_from,periodDate_to,Align) ";
$strSQL .= "VALUES ";
$strSQL .= "('".$result["Cust. Code"]."','".$result["Project Name"]."','".$result["Channel"]."' ";
$strSQL .= ",'".$result["Type"]."','".$result["Condition"]."','".$result["From"]."' ";
$strSQL .= ",'".$result["To"]."') ";
mssql_query($strSQL);
echo $strSQL."<br>";
echo "Row A $i Inserted...<br>";
$strSQL2 = "";
$strSQL2 .= "INSERT INTO pis_discountMat ";
$strSQL2 .= "(material_code,off_invoice,rebate,rebate_2,rebate_3,total,Quota) ";
$strSQL2 .= "VALUES ";
$strSQL2 .= "('".$result["Material"]."','".$result["Off invoice"]."','".$result["Monthly rebate"]."' ";
$strSQL2 .= ",'".$result["Other rebate 1"]."','".$result["Other rebate 2"]."','".$result["Total discount"]."' ";
$strSQL2 .= ",'".$result["Quota (tons)"]."') ";
mssql_query($strSQL2);
echo $strSQL2."<br>";
echo "Row B $i Inserted...<br>";
Tag : PHP
|
ประวัติการแก้ไข 2014-06-25 16:28:35 2014-06-25 16:37:37
|
 |
 |
 |
 |
Date :
2014-06-25 16:27:31 |
By :
flintstone |
View :
968 |
Reply :
5 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ฟิวไม่เท่ากัน ตรวจสอบตัวแปรครับ
|
 |
 |
 |
 |
Date :
2014-06-25 17:31:24 |
By :
progamer2000 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเขียนแบบนรี้ไหมครับ ไม่ต้องกลัวหลง field
insert into table set field1='data1', field2='data2'
รับรองไม่ต้องกลัวว่า field จะไม่เท่ากัน
|
 |
 |
 |
 |
Date :
2014-06-25 21:19:22 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเช็คแล้วครับ error แรกฟิล์ดไม่เท่ากันจริงๆครับ แต่หลังจากนั้นติดปัญหา convert date ครับ
เนื่องจากตอนแสดงผลผมใช้คำสั่งด้านล่างครับ พอตอน Insert ค่ากลายเป็นแบบนี้ครับ 41821 ,42004
show(PHP)
<td align="center"><? if($result["From"] != ""){ echo $date_formated = date('d/m/Y', PHPExcel_Shared_Date::ExcelToPHP($result["From"])); } ?></td>
<td align="center"><? if($result["To"] != ""){ echo $date_formated = date('d/m/Y', PHPExcel_Shared_Date::ExcelToPHP($result["To"])); } ?></td>
|
 |
 |
 |
 |
Date :
2014-06-25 22:39:42 |
By :
flintstone |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
field ที่เก็บ date เป็น Type อะไรครับ
|
 |
 |
 |
 |
Date :
2014-06-25 22:52:58 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|