私はMySQLデータベースを更新するPHPフォームを持っています。その行の現在のクレジットにクレジットを追加したい。基本的な数学MYSQL Rowを更新するPHPフォーム
現在のクレジットは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' が"。 "ID = $ ID" が、 – cmnardi