我有一個PHP表單來更新MySQL數據庫。我想爲行中的當前積分添加積分。基本的數學PHP表單來更新MYSQL行
當前積分50再添50個積分= 100
這是我當前字符串(編者)
$sql = sprintf("UPDATE h_clients ". "SET credits = $credits + '%s'" . "WHERE id = $id",
Currently this works but it doesn't add the new credits with the current credits in DB
Here is the full code:
$sql = sprintf("UPDATE h_clients ". "SET credits = $credits + '%s'" . "WHERE id = $id",
mysql_real_escape_string($credit),
mysql_real_escape_string($id));
if (mysql_query($sql, $con)) {
$insertSuccessful = true;
} else {
echo $sql;
echo "\n" . mysql_error($con);
echo "mysql err no : " . mysql_errno($con);
}
}
}
return $insertSuccessful;
試$ SQL = sprintf的( 「UPDATE h_clients」。 「SET學分=學分+ '%s' 的。」 「WHERE ID = $ id爲」 有錯誤的列名, – cmnardi