This question already has answers here:
Why do I get the MySQL Error “Query was empty”?
(3个答案)
6年前关闭。
这是为了从URL获取数据并将其提交到数据库,这会导致错误:
查询为空;
我在其中进行了更多测试,是的,它给出了我设置的变量的值。提前致谢
(3个答案)
6年前关闭。
这是为了从URL获取数据并将其提交到数据库,这会导致错误:
查询为空;
我在其中进行了更多测试,是的,它给出了我设置的变量的值。提前致谢
<?php
require 'variables.php';
if(empty($_REQUEST['Key']) || empty($_REQUEST['Computer']) || empty($_REQUEST['Panel'])){
die("Nothing was given for me to give back :(");
}else{
$key = $_REQUEST['Key'];
$computer = $_REQUEST['Computer'];
$panel = $_REQUEST['Panel'];
$insertquery = mysql_query("INSERT INTO keys (Key, PC, Panel) VALUES ('".$key."', '".$computer."', '".$panel."')");
$sql = mysql_query($insertquery);
if($sql){
echo "good ". mysql_error();
}else{
echo "bad ". mysql_error();
echo "<br />".$key." ".$computer." ".$panel."";
}
}
?>
最佳答案
您正在拨打mysql_query()
两次。那就是问题所在
像这样
<?php
require 'variables.php';
if(empty($_REQUEST['Key']) || empty($_REQUEST['Computer']) || empty($_REQUEST['Panel'])){
die("Nothing was given for me to give back :(");
}else{
$key = $_REQUEST['Key'];
$computer = $_REQUEST['Computer'];
$panel = $_REQUEST['Panel'];
$insertquery = "INSERT INTO keys (Key, PC, Panel) VALUES ('".$key."', '".$computer."', '".$panel."')";
$sql = mysql_query($insertquery);
if($sql){
echo "good ". mysql_error();
}else{
echo "bad ". mysql_error();
echo "<br />".$key." ".$computer." ".$panel."";
}
}
?>
10-06 06:02