我的PHP腳本存在問題。當我運行該腳本,它顯示了一個錯誤:PHP中的MySQLi查詢錯誤
mysqli_query() expects at least 2 parameters, 1 given
的錯誤是在這一行:
$result=mysqli_query($selectQuery);
我的腳本如下:
global $conn;
$prod_cat_names = "'" . str_replace(",", "','", $values["prod_cat"]) . "'";
/* Select Query as SELECT from previous example: */
$selectQuery =
"
SELECT sup_id, sup_name, sup_prod_name, sup_contactperson, sup_email, ".$values["tender_id"]."
FROM view_rfq_suppliersmerge
WHERE sup_prod_name IN ({$prod_cat_names})
GROUP BY sup_name
";
/* Perform the query: */
$result=mysqli_query($selectQuery);
//$result = $db->query($selectQuery);
//$result->setFetchMode(PDO::FETCH_ASSOC);
$insertQuery = array();
/* Process result and pre-fill Insert Query: */
while($row=db_fetch_array($result))
{
$insertQuery[] = "'" . implode("', '",$row) . "'";
}
/* Format INSERT Query: */
$insertQuery =
"
INSERT INTO rfq_suppliers
(sup_id, sup_name, sup_product, sup_contactperson, sup_contactperson_email, tender_id)
VALUES
('
. implode('), (', $insertQuery)
')
";
/* Perform INSERT Query: */
db_exec($insertQuery,$conn);
添加db鏈接作爲第一個參數。您需要提供數據庫鏈接作爲第一個參數。閱讀手冊http://php.net/manual/en/mysqli.query.php –
你甚至讀過錯誤信息嗎? –
是的,我沒有,無法解決,這就是爲什麼張貼在這裏 –