2015-10-19 55 views
0

我正在嘗試做一個mysqli_multi_query。由於某種原因,它沒有成功。 以下是我迄今所做的:mysqli_multi_query不工作,什麼也沒有發生

<?php 
$con=mysqli_connect("host","user","pw","db"); 

if (mysqli_connect_errno()) 
    { 
    echo "Failed to connect to MySQL: " . mysqli_connect_error(); 
    } 

    $orderid = $_GET['orderid']; 
    $sql = "INSERT INTO orders_archive SELECT * FROM orders WHERE orders_id='".$orderid."'"; 
    $sql .= "DELETE FROM orders WHERE orders_id='".$orderid."'"; 


mysqli_multi_query($con,$sql); 

mysqli_close($con); 
?> 

orderid由阿賈克斯給出了過來。

回答

1

查詢必須用;分開。

$sql = "INSERT INTO orders_archive SELECT * FROM orders WHERE orders_id='".$orderid."';"; 
$sql .= "DELETE FROM orders WHERE orders_id='".$orderid."'"; 
+0

好,真正解決它。非常感謝你!這是多麼容易... –

+0

有時候,另一雙眼睛是所有需要的。 :) –

1

您需要在查詢的末尾添加semicolun到sepetare它

$sql = "INSERT INTO orders_archive SELECT * FROM orders WHERE orders_id='".$orderid."';"; 
$sql .= "DELETE FROM orders WHERE orders_id='".$orderid."'"; 
相關問題