我使用一個簡單的表格,並提交我的文本框的值到數據庫,爲什麼我的表單不能在PHP中發佈?
<body>
<?php
if(isset($_POST["submit"]))
$des="Insert into enquiry(Companyname,Name,Phno,Email,Address,Comments) values
('".$_POST[txtcompname]."','".$_POST[txtname]."','".$_POST[txtphno]."',
'".$_POST[txtemail]."','".$_POST[txtaddress]."','".$_POST[txtcomments]."')";
$res1=mysql_query($des);
?>
<div align="left">
<form action="" method="post">
但它似乎並沒有得到提交?任何建議
當我使用print_r($_POST);
我得到
Array ([txtcompname] => xv [txtname] => xcv [txtphno] => xcvx [txtemail] => xcv [txtaddresss] => xcv [txtcomments] => xcvxcv [submit] => submit)
,現在我得到這個錯誤,
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 'Address,Comments)
values ('zdc','sadcv','zdsv', 'sdcv','sdvcsdv','sdcv')' at line 2
之間的空間你明白了什麼,當你'的print_r($ _ POST);'? – fabrik 2010-09-22 10:12:47
你確定你有提交給表單的'submit'元素嗎?你應該真的這麼做:'if($ _ POST){}'這會給你相同的結果。 MySQL也應該是首都。是否有一個mysql_error?把'$ res1 = mysql_query($ des);'改成'$ res1 = mysql_query或者die(mysql_error());' – 2010-09-22 10:15:56
沒關係。您的表單已提交。你有什麼錯誤嗎? – fabrik 2010-09-22 10:20:48