gpt4 book ai didi

php - SQL语法的MySQL服务器版本错误,要求在 'CompletedNo SELECT (OrderNo.) FROM `顺序附近使用正确的语法

转载 作者:行者123 更新时间:2023-12-03 08:27:59 25 4
gpt4 key购买 nike

以下php脚本用于从数据库中检索数据集(订单号)!当单击删除链接时,我要删除该特定删除链接所在的行,并将数据传输到“传输”表中!

<?php
require("includes/db.php");

$sql="SELECT * FROM `order` ";
$result=mysqli_query($db,$sql);
echo"<head>";
echo'
<link rel="stylesheet" href="view.css">
<head>


';
echo"</head>";

echo "<body >";
echo "<table border=1 cellspacing=0 cellpadding=4 > " ;
echo"<tr bgcolor=grey>";
echo"<td align=center>";
echo "<font size=4>";
echo "<B>";
echo "Order No.";
echo "</B>";
echo"</td>";
echo"</tr>";


while($row=mysqli_fetch_array($result))
{

echo"<tr>";
echo"<td align=center>";
echo $row["OrderNo."];
echo "<br>";
echo"</td>";
echo "<td align=center>";
echo "<a href='delete.php?del=";
echo $row['OrderNo.'];
echo "'>delete</a>";
echo "<br>";
echo"</td>";
echo"</tr>";
}
echo"</table>";

?>

单击删除链接后,将执行以下php脚本!当仅执行删除功能的查询时,它起作用,但是在插入另一个查询以将值传输到“传输”表后,编写了一种语法
发生了错误。
<?php
include("includes/db.php");

if( isset($_GET['del']) )
{
$id = $_GET['del'];
$sql1="INSERT INTO transfer CompletedNo SELECT (OrderNo.) FROM `order` WHERE `OrderNo.` = '$id' ";
$res1= mysqli_query($db,$sql1) or die("Failed".mysqli_error($db));
$sql2= "DELETE FROM `order` WHERE `OrderNo.` = '$id' ";
$res2= mysqli_query($db,$sql2) or die("Failed".mysqli_error($db));

}
?>

请帮助我改正错误仅在网上
$sql1="INSERT INTO transfer CompletedNo SELECT (OrderNo.) FROM `order` WHERE `OrderNo.` = '$id' ";

最佳答案

您需要在Parenthesis列列表周围使用Insert

INSERT INTO transfer (CompletedNo) 
SELECT `OrderNo.` FROM `order` WHERE `OrderNo.` = '$id'

关于php - SQL语法的MySQL服务器版本错误,要求在 'CompletedNo SELECT (OrderNo.) FROM `顺序附近使用正确的语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40044242/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com