亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Mysqli_Query警告:mysqli_query()期望參數1為mysqli

Mysqli_Query警告:mysqli_query()期望參數1為mysqli

慕容森 2019-08-14 15:28:51
Mysqli_Query警告:mysqli_query()期望參數1為mysqli 我的代碼中出現此錯誤,我不知道如何解決我的代碼:<?phpsession_start();include_once"connect_to_mysql.php";$db_host = "localhost";// Place the username for the MySQL database here$db_username = "root"; // Place the password for the MySQL database here$db_pass = "****"; // Place the name for the MySQL database here$db_name = "mrmagicadam";// Run the actual connection here $myConnection= mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql");mysql_select_db("mrmagicadam") or die ("no database");        $sqlCommand="SELECT id, linklabel FROM pages ORDER BY pageorder ASC";$query=mysqli_query($myConnection, $sqlCommand) or die(mysql_error());$menuDisplay="";while($row=mysql_fetch_array($query)) {    $pid=$row["id"];    $linklabel=$row["linklabel"];$menuDisplay='<a href="index.php?pid=' .$pid . '">' .$linklabel. '</a><br/>';}mysqli_free_result($query);?>這是錯誤的:警告:mysqli_query()期望參數1為mysqli,第17行的C:\ xampp \ htdocs \ limitless \ connect_to_mysql.php中給出的資源我做錯了什么?
查看完整描述

2 回答

?
慕標5832272

TA貢獻1966條經驗 獲得超4個贊

你正在混合mysqlimysql擴展,這將無法正常工作。

你需要使用

$myConnection= mysqli_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql"); mysqli_select_db($myConnection, "mrmagicadam") or die ("no database");

mysqli與原始mysql擴展相比有許多改進,因此建議您使用mysqli。


查看完整回答
反對 回復 2019-08-14
  • 2 回答
  • 0 關注
  • 1057 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號