php脚本不执行mysql命令。为什么?在后端测试mysql脚本时,它可以正常工作。
谢谢你的建议!我考虑了这个事实。不管怎样。。我的查询如下所示,不起作用或不产生任何错误。插入到标记(id,tags,givetake,onoff,tagnumber)值('1234','jjj','0','0','1')
当它复制到数据库后端它的工作非常完美。。。
<?php
require_once('XXXX.php');
//Variables for Authentication.
$server_key = md5("XXXXX");
$server_auth = $_POST["XXXXX"];
if($server_auth == $server_key)
{
//Established the connection to the mySQL server.
$connection = new mysqli($server_name, $database_user, $database_password, $database_name);
if($connection)
{
//Variables for userdatabase.
//$firstName = $_POST["userFirstName"];
//$lastName = $_POST["userLastName"];
//$email = $_POST["userEmail"];
//$password = $_POST["userPassword"];
$id = $_POST["id"];
$tags = $_POST["tags"];
$giveTake= $_POST["giveTake"];
$onOff = $_POST["onOff"];
$tagNumber = $_POST["tagNumber"];
// echo $firstName . ' ' . $lastName;
//Getting data from the database.
echo("vor SQL insert");
$sql = "INSERT INTO tags (id, tags, giveTake, onOff, tagNumber) VALUES ('".$id."','".$tags."','".$giveTake."','".$onOff."','".$tagNumber."')";
echo $sql;
$result = mysqli_query($connection, $sql);
echo $result;
if($result)
{
echo ("Success.");
}
else
{
die("Coo0nection Failed.".mysql_connect_error());
echo("Cooonnection Failed.");
}
}
}
else
{
echo("Error.");
}
?>
1条答案
按热度按时间z9smfwbn1#
如果在db中是int,则从id中删除引号。int不需要引号,这将导致查询失败,如果$tagnumber是int,则删除单引号。希望有帮助。