0

我已经看过并且无法告诉我的错误在哪里如果有人看到我看不到的东西你能指出我正确的方向来解决这里是我的代码

 $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);
 ?>
4

1 回答 1

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']}")

对于复杂变量,您需要使用 {}语法

于 2013-05-19T23:40:08.410 回答