Php mysqli:更新用户,其中金额少于x并删除查询

时间:2018-02-09 18:26:16

标签: php mysqli

这个,它确实删除金额少于1的地方 但它没有更新用户,为什么不呢?谁能告诉我?

$data1 = mysqlI_query($link,"SELECT * FROM bubble_spends where burst <= 0");
$data  = mysqli_fetch_array($data1);

$burst123='$data[burst]';
$username123='$data[username]';
IF($data1)
{
    mysqli_query($link,"UPDATE * FROM 'users' SET 'bitcoins'='bitcoins'-'$burst123' WHERE 'username' = '$username123' ");
    mysqli_query($link,"DELETE FROM bubble_spends where amount <= 1");
}

Greets Patrick

1 个答案:

答案 0 :(得分:0)

  1. 更新查询语法错误,查询正确
  2. 更新users设置bitcoins = bitcoins - $ burst123 WHERE username ='$ username123'

    1. 从表名和列名中删除单引号(')并改为使用tick(`)。例如更新*来自'用户'SET'比特币'='比特币' - '$ burst123'WHERERE'用户名'='$ username123'
    2. 您正在使用此'$ burst123',它被视为字符串。
    3. 更新了查询:

      $data1 = mysqli_query($link,"SELECT * FROM bubble_spends where burst <= 0");
      $data  = mysqli_fetch_array($data1);
      
      $burst123='$data[burst]';
      $username123='$data[username]';
      IF($data1)
      {
          mysqli_query($link,"UPDATE `users` SET `bitcoins`=`bitcoins`- $burst123 WHERE `username` = '$username123' ");
          mysqli_query($link,"DELETE FROM bubble_spends where amount <= 1");
      }