我有几个查询字符串,我想使用“mysqli_multi_query”一次执行。这行得通。
当我再次插入查询以使用“mysqli_query”检查连接表中的每个项目时,它不会从 PHP 返回任何结果或任何错误。当我在 phpmyadmin 中手动运行查询字符串时,一切正常。
这是我的代码:
<?php
$connect = mysqli_connect('localhost','root','','database');
$strquery = "";
$strquery .= "1st Query";
$strquyer .= "2nd Query";
if($multi = mysqli_multi_query($connect,$strquery)){ // function mysqli_multi_query is working
// From here it doesn't give any response
$qryarray = mysqli_query($connect,
"SELECT purchase_detail_$_SESSION[period].item_code,
purchase_detail_$_SESSION[period].location_code
FROM purchase_detail_$_SESSION[period]
WHERE purchase_detail_$_SESSION[period].purchase_num = '$_POST[purchase_num]'
UNION
SELECT purchase_detail_temp.item_code,
purchase_detail_temp.location_code
FROM purchase_detail_temp
WHERE purchase_detail_temp.purchase_num = '$_POST[purchase_num]' AND purchase_detail_temp.username = '$_SESSION[username]'");
while($array = mysqli_fetch_array($qryarray)){
"Some code to process several item code in table purchase_detail_$_SESSION[period]"
}
}
我的代码有什么问题吗?