我认为您将能够快速解决此问题。我可能是语法错误。我有一个表“行会”,我正在尝试更新一个值“点”。我认为语法有问题。有人能帮忙吗?
$guild = $_POST["guild"];
$pointsToAdd = $_POST["pointsAdd"];
$updatePointsQuery = "UPDATE guild SET points = points + " . $pointsToAdd . " WHERE name = '" . $guild . "';";
mysqli_query($con, $updatePointsQuery) or die("error code #4: points could not be updated"); //error 4 insert query failed
错误代码:[31-Jan-2019 09:03:38 UTC] PHP警告:在第21行的E:\ MAMP \ htdocs \ sqlconnect \ addclanpoint.php中遇到一个非数字值
答案 0 :(得分:0)
我假设字符串中的点是一个表列。你首先需要获得积分,并放置在一个变量
$guild = $_POST["guild"];
$pointsToAdd = $_POST["pointsAdd"];
$currentPoints = "SELECT points FROM guild WHERE name = '" . $guild . "'";
$updatePointsQuery = "UPDATE guild SET points = " . $currentPoints + $pointsToAdd . " WHERE name = '" . $guild . "'";