0

I have looked and can not tell where my Error is if any one see something that i do not can you point me in the right direction to fix here is my code

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

1 Answers1

4

Change

mysqli_query($con,"UPDATE $table_name SET energy = $newenergy WHERE uuid =$row['uuid']")

To

mysqli_query($con,"UPDATE $table_name SET energy = $newenergy WHERE uuid ={$row['uuid']}")

For complex variables, you need to use the {} syntax.

radicalpi
  • 907
  • 1
  • 9
  • 29