dongye8110 2016-10-14 13:20
浏览 125
已采纳

SQL语法中的错误MySQL服务器版本的正确语法使用在'CompletedNo SELECT(OrderNo。)FROM`order` WHERE`OrderNo附近。

The following php script is used to retrieve set of data(OrderNo.) from a database! when the delete link is clicked i want to remove the row in which that specific delete link exists and transfer the data to the 'transfer' table!

<?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>";

?>

The following php script is executed when a delete link is clicked! when only the query for the delete function was executed it worked but after insertion of another query to transfer the values to 'transfer' table was written a syntax error occured.

<?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));

    }
?>

please help me to correct it the error is only on line

$sql1="INSERT INTO transfer CompletedNo SELECT (OrderNo.) FROM `order` WHERE `OrderNo.` = '$id' ";
  • 写回答

1条回答 默认 最新

  • dongpu2727 2016-10-14 13:21
    关注

    You need to use Parenthesis around the Insert column list

    INSERT INTO transfer (CompletedNo) 
    SELECT `OrderNo.` FROM `order` WHERE `OrderNo.` = '$id' 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)