我正在尝试使用 AJAX 和 PHP 更新我的数据库。我确信一切都是正确的,只有我的页面刷新并且没有插入到我的表格中。
HTML
<form id="salary-upd">
<input type="text" class="defaultText" id="monthly-income" name="monthly-income" title="What is your salary?">
<input type="submit" class="salary-upd-submit">
</form>
<div></div>
AJAX
// UPDATE INCOME
$(".salary-upd-submit").click(function() {
var elem = $(this);
$.post("update_salary.php", elem.parent("#salary-upd").serialize(), function(data) {
elem.next("div").html(data);
});
});
PHP
$uid = $_SESSION['oauth_id'];
$monthly_income = $_POST['monthly-income'];
#update Record
$query = mysql_query("SET `income` (user_id, monthly_income) VALUES ($uid, '$monthly_income')") or die(mysql_error());
试图更新我的PHP,因为我认为它可能是......
$query = mysql_query("UPDATE `income` SET (user_id, monthly_income) VALUES ($uid, '$monthly_income')") or die(mysql_error());