 |
[PHP]
ช่วยดูโคด insert ให้หน่อยครับผิดตรงใหนมัน Err ทั้งข้อมูลเข้ามานะครับ |
|
 |
|
|
 |
 |
|
Code (PHP)
01. <?php
02. session_start();
03. $ses_userid = $_SESSION [ses_userid];
04. $ses_username = $_SESSION [ses_username];
05. if ( $ses_userid <> session_id() or $ses_username == "" ){
06. echo "คุณยังไม่ได้ทำการ Log in" ;
07. echo "<meta http-equiv='refresh' content='2;URL=../index.php' />" ;
08. } else {
09. ?>
10. <html>
11. <head>
12. <title>ThaiCreate.Com PHP & MySQL Tutorial</title>
13. <meta http-equiv= "Content-Type" content= "text/html; charset=windows-874" ></head>
14. <body>
15. <?
16. include ( "../Connections/dbconn.inc.php" );
17. $strSQL = "INSERT INTO staff " ;
18. $strSQL .= "(staf_no,staf_user,staf_pass,staf_prefix,staf_name,staf_lass,staf_sex, staf_position,staf_hn,staf_moo,staf_road,staf_distric,staf_tdistric,staf_province,staf_ptc,staf_phone) VALUES ('" . $_POST [ "staf_no" ]. "','" . $_POST [ "staf_user" ]. "','" . $_POST [ "staf_pass" ]. "', '" . $_POST [ "staf_prefix" ]. "','" . $_POST [ "staf_name" ]. "','" . $_POST [ "staf_lass" ]. "' ,'" . $_POST [ "staf_psex" ]. "','" . $_POST [ "staf_position" ]. "','" . $_POST [ "staf_hn" ]. "' ,'" . $_POST [ "staf_moo" ]. "','" . $_POST [ "staf_road" ]. "','" . $_POST [ "staf_distric" ]. "' ,'" . $_POST [ "staf_tdistric" ]. "','" . $_POST [ "staf_province" ]. "' ,'" . $_POST [ "staf_ptc" ]. "','" . $_POST [ "staf_phone" ]. "') " ;
19. $objQuery = mssql_query( $strSQL );
20. if ( $objQuery )
21. {
22. echo "<script>alert('บันทึกข้อมูลเรียบร้อยแล้ว')</script>" ;
23. echo "<meta http-equiv='refresh' content='0;URL=satafshowe.php'>" ;
24. }
25. else
26. {
27. echo "<script>alert ('Error Save [" . $strSQL . "]')</script>" ;
28. echo "<meta http-equiv='refresh' content='0;URL=satafadd.php'>" ;
29. }
30. ?>
31. </body>
32. </html>
33. <?php
34. }
35. ?>
Code
Fatal error: Call to undefined function mssql_query() in D:\AppServ\www\project\staf\add.php on line 19
Tag : PHP
|
|
 |
 |
 |
 |
Date :
2012-03-23 11:21:12 |
By :
kooyarut |
View :
1084 |
Reply :
6 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่ได้เปิดใช้ mssql มั้งครับ ใน php.ini
|
 |
 |
 |
 |
Date :
2012-03-23 11:31:04 |
By :
randOmizE |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยังไม่ได้ครับแก้ไม่หมดแล้ว
Code (PHP)
01. <?php
02. session_start();
03. $ses_userid = $_SESSION [ses_userid];
04. $ses_username = $_SESSION [ses_username];
05. if ( $ses_userid <> session_id() or $ses_username == "" ){
06. echo "คุณยังไม่ได้ทำการ Log in" ;
07. echo "<meta http-equiv='refresh' content='2;URL=../index.php' />" ;
08. } else {
09. ?>
10. <html>
11. <head>
12. <title>ThaiCreate.Com PHP & MySQL Tutorial</title>
13. <meta http-equiv= "Content-Type" content= "text/html; charset=windows-874" ></head>
14. <body>
15. <?
16. include ( "../Connections/dbconn.inc.php" );
17. $strSQL = "INSERT INTO staff " ;
18. $strSQL .= "(staf_no,staf_user,staf_pass,staf_prefix,staf_name,staf_lass,staf_sex,staf_position, staf_hn,staf_moo,staf_road,staf_distric,staf_tdistric,staf_province,staf_ptc,staf_phone) VALUES ('" . $_POST [ "staf_no" ]. "','" . $_POST [ "staf_user" ]. "','" . $_POST [ "staf_pass" ]. "' ,'" . $_POST [ "staf_prefix" ]. "','" . $_POST [ "staf_name" ]. "','" . $_POST [ "staf_lass" ]. "' ,'" . $_POST [ "staf_sex" ]. "','" . $_POST [ "staf_position" ]. "','" . $_POST [ "staf_hn" ]. "' ,'" . $_POST [ "staf_moo" ]. "','" . $_POST [ "staf_road" ]. "','" . $_POST [ "staf_distirc" ]. "', '" . $_POST [ "staf_tdistirc" ]. "','" . $_POST [ "staf_province" ]. "','" . $_POST [ "staf_ptc" ]. "','" . $_POST [ "staf_phone" ]. "') " ;
19. $objQuery = mysql_query( $strSQL );
20. if ( $objQuery )
21. {
22. echo "Save Done." ;
23. }
24. else
25. {
26. echo "Error Save [" . $strSQL . "]" ;
27. }
28. ?>
29. </body>
30. </html>
31. <?php
32. }
33. ?>
Code
Error Save [INSERT INTO staff (staf_no,staf_user,staf_pass,staf_prefix,staf_name,staf_lass,staf_sex,staf_position,staf_hn,staf_moo,staf_road,staf_distric,staf_tdistric,staf_province,staf_ptc,staf_phone) VALUES ('001','u','s','นาง','ก','บ','หญิง','0','2','1','พ','ค','ด','กรุงเทพมหานคร ','91160','0') ]
|
 |
 |
 |
 |
Date :
2012-03-23 11:49:30 |
By :
kooyarut |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เปลี่ยน จาก echo "Error Save [".$strSQL."]"; เป็น echo mysql_error(); จะได้รู้ว่า error ตรงไหน
|
 |
 |
 |
 |
Date :
2012-03-23 12:34:53 |
By :
randOmizE |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
random ขอบตุณครับได้แว้
|
 |
 |
 |
 |
Date :
2012-03-23 13:22:29 |
By :
kooyarut |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|