PHP未在mysql表中插入数据

PHP未在mysql表中插入数据,php,mysql,Php,Mysql,非常简单的代码 $device = $_GET['device']; $voltage = $_GET['voltage']; $current = $_GET['current']; $power = $current * $voltage; mysqli_query($connect, "insert into device$device (time, voltage, current, power) values (curtime(), $voltage, $current, $

非常简单的代码

$device = $_GET['device'];
$voltage = $_GET['voltage'];
$current = $_GET['current'];
$power = $current * $voltage;

mysqli_query($connect, "insert into device$device (time, voltage, current, power)
    values (curtime(), $voltage, $current, $power);");
问题是,无论我输入什么设备号,它都能工作。它只适用于设备1。mysql数据库或php代码没有改变任何东西,只是突然不再工作,除非
$device=1

也没有报告任何错误

$device1 = $_GET['device']; 
 $device = "device".$device1;
  mysqli_query($connect, "insert into  '".$device." (time, voltage, current, power)
values (curtime(), '$voltage', '$current', '$power')");
更改查询

mysqli_query($connect, "insert into device'".$device."' (time, voltage, current, power)
values (curtime(), $voltage, $current, $power);");


因为
$device
是一个整数。

是否将设备与设备名称合并?哪些
$device
值不起作用?您可以尝试将表名包装为backticks->
插入“设备$device”…
您的表名是如何变成的:device1,device2???可能是阅读的好时机。切勿直接在查询中使用用户数据,
$\u GET
。消毒消毒消毒!警告:使用
mysqli
时,您应该使用和将用户数据添加到查询中。不要使用字符串插值或串联来完成此操作,因为您已经创建了严重的错误。切勿将
$\u POST
$\u GET
数据直接放入查询中,如果有人试图利用您的错误进行攻击,这可能非常有害。是否显示任何错误??如果是,请描述它打印查询,然后用四个空格或
{}
按钮检查查询代码格式中实际发生的情况。
mysqli_query($connect, "insert into device".$device." (time, voltage, current, power) values (curtime(), $voltage, $current, $power);");