我已经看了,不知道我的错误在哪里,如果有人看到我不知道的东西,你可以指出我正确的方向来修复这里是我的代码
$con=mysqli_connect("localhost", $user_name, $password, $database_name);
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM `$table_name` WHERE energy < 30");
while($row = mysqli_fetch_array($result))
{
$newenergy = $row['energy'] + 1;
mysqli_query($con,"UPDATE $table_name SET energy = $newenergy WHERE uuid =$row['uuid']");
}
enter code here
mysqli_close($con);
?>
答案 0 :(得分:4)
更改
mysqli_query($con,"UPDATE $table_name SET energy = $newenergy WHERE uuid =$row['uuid']")
要
mysqli_query($con,"UPDATE $table_name SET energy = $newenergy WHERE uuid ={$row['uuid']}")
对于复杂变量,您需要使用{} syntax。