無論有多少網站嘗試讓這個工作起來,它仍然沒有。我無法將輸入的數據最終輸入到數據庫中。表單提交,但不會返回錯誤。在phpMyAdmin中查看時,沒有記錄。我已經調整了一百萬次,沒有運氣。第二套眼睛能告訴我我做錯了什麼嗎?無法將數據從php表單發佈到mysql中
謝謝!
添
<body>
<form action="insert.php" method="post"><br>
Date: <input type="text" name="date" id="date"><br>
Time: <input type="text" name="time" id="time"><br>
City: <input type="text" name="city" id="city"><br>
Fire Dept: <input type="text" name="fire" id="fire"><br>
Address: input type="text" name="addy" id="addy"><br>
Call Type/Level <input type="text" name="level" id="level"><br>
Description: <input type="text" name="desc" id="desc"><br>
Units: <input type="text" name="units" id="units"><br>
Submitted by: <input type="text" name"who" id="who"><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
<?php
if (isset($_POST['submit'])){
$db=mysql_connect("", "", "");
$mydb=mysql_select_db("rm911_incidents");
$date=$_Post['date'];
$time=$_Post['time'];
$city=$_Post['city'];
$fire=$_Post['fire'];
$addy=$_Post['addy'];
$level=$_Post['level'];
$desc=$_Post['desc'];
$units=$_Post['units'];
$who=$_Post['who'];
$sql = "INSERT INTO incidents(date,time,city,fire,addy,level,desc,units,who)
VALUES
('$date','$time','$city','$fire','$addy','$level','$desc','$units','$who')";
$result = mysql_query($sql);
if($result)
{
echo "<br>Input data is successful";
}
else
{
echo ("<br>Input data has failed");
}
}
?>
好了,所以我有固定利奧提到(謝謝!),但是這不是問題,或者錯誤。我使用您提供的錯誤報告的錯誤是:未定義索引:xxx ...(xxx是數據庫中的每個字段名稱)。我在數據庫中有一個'id'字段,auto_increment-ing - 我忘了將它設置爲索引嗎?
[**請不要在新代碼中使用'mysql_ *'函數**](http://bit.ly/phpmsql)。他們不再被維護[並且被正式棄用](http://j.mp/XqV7Lp)。看到[**紅框**](http://j.mp/Te9zIL)?學習[*準備的語句*](http://j.mp/T9hLWi),並使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/ mysqli) - [這篇文章](http://j.mp/QEx8IB)將幫助你決定哪個。如果你選擇PDO,[這裏是一個很好的教程](http://j.mp/PoWehJ)。 – rekire
運行腳本時輸出的內容是什麼?它顯示失敗的消息嗎? – 1337holiday
它在你的服務器日誌上說了什麼。需要看到一個錯誤。粗略瀏覽一下,我沒有注意到任何東西,但老的惡化的PHP編碼。而不是Mysql_使用pdo。 –