 |
[PHP]
Warning: mssql_query() [function.mssql-query]: Query failed in |
|
 |
|
|
 |
 |
|
add

addform.php
Code (PHP)
01. <html>
02. <head>
03.
04. </head>
05. <body>
06. <?php include ( "bar.php" ); ?>
07. <form action= "addsaveform.php" name= "frmAdd" method= "post" >
08. <table width= "600" border= "1" >
09. <tr>
10. <th width= "91" > <div align= "center" >CitizenID </div></th>
11. <th width= "160" > <div align= "center" >Prefix </div></th>
12. <th width= "198" > <div align= "center" >FirstName </div></th>
13. <th width= "97" > <div align= "center" >LastName </div></th>
14. <th width= "70" > <div align= "center" >Telmobil1 </div></th>
15. <th width= "70" > <div align= "center" >Mail1 </div></th>
16. <th width= "70" > <div align= "center" >WebMail1 </div></th>
17. <th width= "70" > <div align= "center" >CurLevel </div></th>
18. <th width= "70" > <div align= "center" >student_code_status </div></th>
19. <th width= "70" > <div align= "center" >std_status </div></th>
20. <th width= "70" > <div align= "center" >province </div></th>
21.
22.
23. </tr>
24. <tr>
25. <td><div align= "center" ><input type= "text" name= "txtCitizenID" size= "20" ></div></td>
26.
27. <td><input type= "text" name= "txtPrefix" size= "20" ></td>
28.
29. <td><input type= "text" name= "txtFirstName" size= "20" ></td>
30.
31. <td><div align= "center" ><input type= "text" name= "txtLastName" size= "20" ></div></td>
32.
33. <td align= "right" ><input type= "text" name= "txtTelmobil1" size= "20" ></td>
34.
35. <td align= "right" ><input type= "text" name= "txtMail1" size= "20" ></td>
36.
37. <td align= "right" ><input type= "text" name= "txtWebMail1" size= "20" ></td>
38.
39. <td align= "right" ><input type= "text" name= "txtCurLevel" size= "20" ></td>
40.
41. <td align= "right" ><input type= "text" name= "txtstudent_code_status" size= "20" ></td>
42.
43. <td align= "right" ><input type= "text" name= "txtstd_status" size= "20" ></td>
44.
45. <td align= "right" ><input type= "text" name= "txtprovince" size= "20" ></td>
46.
47.
48.
49. </tr>
50. </table>
51. <input type= "submit" name= "submit" value= "submit" >
52. </form>
53. </body>
54. </html>
addsaveform.php
Code (PHP)
01. <html>
02. <head>
03. </head>
04. <body>
05. <p>
06. <?php
07. include ( "config.php" );
08. include ( "bar.php" );
09. $strSQL = "SELECT * FROM v_studentmail WHERE CitizenID = '" . $_POST [ "txtCitizenID" ]. "' " ;
10. $objQuery = mssql_query( $strSQL );
11. $objResult = mssql_fetch_array( $objQuery );
12. if ( $objResult )
13. {
14. echo "CitizenID already exist." ;
15. }
16. else
17. {
18.
19. $strSQL = "" ;
20. $strSQL = "INSERT INTO v_studentmail " ;
21. $strSQL .= "(CitizenID,Prefix,FirstName,LastName,Telmobil1,Mail1,WebMail1,CurLevel,student_code_status,std_status,province) " ;
22. $strSQL .= "VALUES " ;
23. $strSQL .= "('"
24. . $_POST [ "txtCitizenID" ]. "','"
25. . $_POST [ "txtPrefix" ]. "','"
26. . $_POST [ "txtFirstName" ]. "' " ;
27.
28. $strSQL .= ",'"
29. . $_POST [ "txtLastName" ]. "','"
30. . $_POST [ "txtTelmobil1" ]. "','"
31. . $_POST [ "txtMail1" ]. "') " ;
32.
33. $strSQL .= ",'"
34. . $_POST [ "txtWebMail1" ]. "','"
35. . $_POST [ "txtCurLevel" ]. "','"
36. . $_POST [ "txtstudent_code_status" ]. "') " ;
37.
38. $strSQL .= ",'"
39. . $_POST [ "std_status" ]. "','"
40. . $_POST [ "province" ]. "') " ;
41.
42. $objQuery = mssql_query( $strSQL );
43. if ( $objQuery )
44. {
45. echo "Save Done." ;
46. }
47. else
48. {
49. echo "Error Save [" . $strSQL . "]" ;
50. }
51. }
52. mssql_close( $objConnect );
53. ?>
54. </p>
55. <p> </p>
56. </body>
57. </html>
Tag : PHP
|
ประวัติการแก้ไข 2018-01-18 10:48:45 2018-01-18 11:02:03
|
 |
 |
 |
 |
Date :
2018-01-18 10:46:46 |
By :
shiowa |
View :
984 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ประเด็นคือ ทำไม syntax insert ไม่รวมกันเป็น บรรทัดเดียว และจัดให้ถูกต้องตามลำดับชั้น
แยกหลายบรรทัดจัดงงตายครับ
|
 |
 |
 |
 |
Date :
2018-01-18 11:33:56 |
By :
dudesaranyu |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอบความคิดเห็นที่ : 1 เขียนโดย : dudesaranyu เมื่อวันที่ 2018-01-18 11:33:56
รายละเอียดของการตอบ ::
Code (PHP)
01. <html>
02. <head>
03. </head>
04. <body>
05. <p>
06. <?php
07. include ( "config.php" );
08. include ( "bar.php" );
09. $strSQL = "SELECT * FROM v_studentmail WHERE CitizenID = '" . $_POST [ "txtCitizenID" ]. "' " ;
10. $objQuery = mssql_query( $strSQL );
11. $objResult = mssql_fetch_array( $objQuery );
12. if ( $objResult )
13. {
14. echo "CitizenID already exist." ;
15. }
16. else
17. {
18.
19. $strSQL = "" ;
20. $strSQL = "INSERT INTO v_studentmail " ;
21. $strSQL .= "(CitizenID,Prefix,FirstName,LastName,Telmobil1,Mail1,WebMail1,CurLevel,student_code_status,std_status,province) " ;
22. $strSQL .= "VALUES " ;
23. $strSQL .= "('" . $_POST [ "txtCitizenID" ]. "','" . $_POST [ "txtPrefix" ]. "','" . $_POST [ "txtFirstName" ]. "' " ;
24.
25. $strSQL .= ",'" . $_POST [ "txtLastName" ]. "','" . $_POST [ "txtTelmobil1" ]. "','" . $_POST [ "txtMail1" ]. "') " ;
26.
27. $strSQL .= ",'" . $_POST [ "txtWebMail1" ]. "','" . $_POST [ "txtCurLevel" ]. "','" . $_POST [ "txtstudent_code_status" ]. "') " ;
28.
29. $strSQL .= ",'" . $_POST [ "txtstd_status" ]. "','" . $_POST [ "province" ]. "') " ;
30.
31. $objQuery = mssql_query( $strSQL );
32. if ( $objQuery )
33. {
34. echo "Save Done." ;
35. }
36. else
37. {
38. echo "Error Save [" . $strSQL . "]" ;
39. }
40. }
41. mssql_close( $objConnect );
42. ?>
43. </p>
44. <p> </p>
45. </body>
46. </html>
|
 |
 |
 |
 |
Date :
2018-01-18 12:08:16 |
By :
shiowa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จัดให้เป็นระเบียบ มันคือ Basic ครับ
Code (PHP)
01. <?php
02.
03. $strSQL = "INSERT INTO v_studentmail (CitizenID,Prefix,FirstName,LastName,Telmobil1,Mail1,WebMail1,CurLevel,student_code_status,std_status,province) VALUES" ;
04.
05. $strSQL .= "('" . $_POST [ "txtCitizenID" ]. "','" . $_POST [ "txtPrefix" ]. "','" . $_POST [ "txtFirstName" ]. "','" . $_POST [ "txtLastName" ]."',
06. '".$_POST["txtTelmobil1"]."' , '".$_POST["txtMail1"]."' , '".$_POST["txtWebMail1"]."' , '".$_POST["txtCurLevel"]."' ,
07. '".$_POST["txtstudent_code_status"]."' , '".$_POST["txtstd_status"]."' , '".$_POST["province"]."' )";
08.
09. ?>
|
 |
 |
 |
 |
Date :
2018-01-18 12:23:03 |
By :
dudesaranyu |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอบความคิดเห็นที่ : 3 เขียนโดย : dudesaranyu เมื่อวันที่ 2018-01-18 12:23:03
รายละเอียดของการตอบ ::
ได้แล้วครับ ขอบคุณครับ
ผมลอง
Code (PHP)
01. $strSQL = "" ;
02. $strSQL = "INSERT INTO v_studentmail " ;
03. $strSQL .= "(CitizenID, Prefix, FirstName, LastName, Telmobil1, Mail1,WebMail1,CurLevel,student_code_status,std_status,province) " ;
04. $strSQL .= "VALUES " ;
05. $strSQL .=
06. "('" . $_POST [ "txtCitizenID" ]
07. . "','" . $_POST [ "txtPrefix" ]
08. . "','" . $_POST [ "txtFirstName" ]
09. . "' " ;
10.
11. $strSQL .=
12. ",'" . $_POST [ "txtLastName" ]."'
13. , '".$_POST["txtTelmobil1"]."'
14. , '".$_POST["txtMail1"]."'
15. , '".$_POST["txtWebMail1"]."'
16. , '".$_POST["txtCurLevel"]."'
17. , '".$_POST["txtstudent_code_status"]."'
18. , '".$_POST["txtstd_status"]."'
19. , '".$_POST["txtprovince"]."' ) ";
|
 |
 |
 |
 |
Date :
2018-01-18 13:46:45 |
By :
shiowa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|