本文介紹了警告:mysqli_query() 期望參數 1 是 mysqli,字符串在的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我收到警告:
警告:mysqli_query() 期望參數 1 是 mysqli,在第 6 行的 (...) 中給出的字符串
Warning: mysqli_query() expects parameter 1 to be mysqli, string given in (...) on line 6
我的代碼在這里:
<?php
require_once 'conn.php';
$sql = "SELECT user_id, access_lvl, name FROM cms_users ";
$result = mysqli_query($sql, $conn);
推薦答案
這與您錯誤地將參數傳遞給 mysqli_query()
時的錯誤狀態完全一樣.假設 $conn
是您在某個時候由 new mysqli()
生成的 mysqli 連接,它應該是:
It's exactly as the error states as you're passing arguments to mysqli_query()
incorrectly. Assuming $conn
is your mysqli connection generated at some point by new mysqli()
it should be:
$result = mysqli_query( $conn,$sql) or trigger_error(mysqli_error($conn)));
你調用它的方式是傳遞一個字符串,$sql
作為第一個參數.
The way you were calling it you were passing a string, $sql
as the first argument.
這篇關于警告:mysqli_query() 期望參數 1 是 mysqli,字符串在的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!