gpt4 book ai didi

php - 更新表 mysql & php

转载 作者:行者123 更新时间:2023-11-30 23:55:35 25 4
gpt4 key购买 nike

我有以下代码,它在更新分数和日期时工作正常。但它不会更新行的名称或国家/地区。这与 php 字符串有关吗???很迷茫!

$userName = "John";
$userCountry = "USA";
$lowestScoreId = 99;
$userPoints = 500;


include 'config.php';


$currentTime = time();

mysql_query("UPDATE highScores SET name = $userName WHERE id='$lowestScoreId'");
mysql_query("UPDATE highScores SET score = $userPoints WHERE id='$lowestScoreId'");
mysql_query("UPDATE highScores SET country =$userCountry WHERE id='$lowestScoreId'");
mysql_query("UPDATE highScores SET date = $currentTime WHERE id='$lowestScoreId'");

最佳答案

您忘记了您设置的值周围的引号。您可以在 1 个查询中完成。

UPDATE highScores
SET `name` = '$userName',
`score` = '$userPoints',
`country` = '$userCountry',
`date` = '$currentTime'
WHERE id='$lowestScoreId'"

关于php - 更新表 mysql & php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11676479/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com