โค้ดครับ
<!-- save_sub.php -->
<?
$conn = mysql_connect ("localhost","root","1234") ;
mysql_select_db ("subject") ;
$sql = " insert into subject ( sub_id .sub_name .sub_thea .sub_credit .sub_depart .st_A .st_Bplus .st_B .st_Cplus .st_C .st_Dplus .st_D .st_F .st_W ) values ('$txtId'.'$txtName'.'$txtTeach'.'$txtCredit'.'$txtDepart'.'$txtA'.'$txtBplus'.'$txtB'.'$txtCplus'.'$txtC'.'$txtDplus'.'$txtD'.'$txtF'.'$txtW' ) " ;
$result = mysql_query($sql) or die (mysql_error()) ;
if($result)
print"insert data OK";
else
print"Error";
?>
พอรันออกมาหน้าเว็บเเล้วเป็นแบบนี้
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.sub_credit .sub_depart .st_A .st_Bplus .st_B .st_Cplus .st_C .st_Dplus .st_D .s' at line 1
ช่วยแก้ Error Mysql ทีครับ
<!-- save_sub.php -->
<?
$conn = mysql_connect ("localhost","root","1234") ;
mysql_select_db ("subject") ;
$sql = " insert into subject ( sub_id .sub_name .sub_thea .sub_credit .sub_depart .st_A .st_Bplus .st_B .st_Cplus .st_C .st_Dplus .st_D .st_F .st_W ) values ('$txtId'.'$txtName'.'$txtTeach'.'$txtCredit'.'$txtDepart'.'$txtA'.'$txtBplus'.'$txtB'.'$txtCplus'.'$txtC'.'$txtDplus'.'$txtD'.'$txtF'.'$txtW' ) " ;
$result = mysql_query($sql) or die (mysql_error()) ;
if($result)
print"insert data OK";
else
print"Error";
?>
พอรันออกมาหน้าเว็บเเล้วเป็นแบบนี้
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.sub_credit .sub_depart .st_A .st_Bplus .st_B .st_Cplus .st_C .st_Dplus .st_D .s' at line 1