我有一個問題,我只能將數據插入到我的表中一次。如果我刪除行並插入一個新的,它可以工作,但如果我已經有一行並嘗試插入另一個,它不起作用。控制檯或網絡中沒有錯誤。只能插入到mysql表中一次
我這個插入:
<?php
error_reporting(E_ALL);
include 'DB.php';
$con = mysql_connect($host,$user,$pass)
or die("Error: ".mysql_error());
$dbs = mysql_select_db($databaseName, $con);
$name = mysql_real_escape_string($_POST['name']);
$date = date('Y-m-d');
$amount = $_POST['amount'];
$timPaid = $_POST['timPaid'];
$rennyPaid = $_POST['rennyPaid'];
$sql = "INSERT INTO $tableName (`name`, `date`, `amount`, `timpaid`, `rennypaid`)
VALUES ('$name', '$date', '$amount', '$timPaid', '$rennyPaid')";
$result = mysql_query($sql, $con)
or die("Error: ".mysql_error());
mysql_close($con);
?>
我想這可能與我的表是如何設置,主鍵和這樣做。我有一個ID列,這是主要的,我認爲它是自動增量,不能說。
你有什麼錯誤? – 2013-05-03 05:25:11
我沒有得到任何錯誤:( – 2013-05-03 05:25:46
如果你認爲這是一個問題,你的桌子是如何設置的,請張貼表格定義 另外,請看看我的回答你的其他問題。一個錯誤,但是因爲你發佈了AJAX請求,你必須在服務器端日誌中找到錯誤,或者查看開發者控制檯中的請求結果(chrome) – 2013-05-03 05:26:38