我正在尝试按照 YouTube 教程构建 CMS。我开始对它创建的错误消息感到非常困惑。我收到以下错误
警告:mysqli_query() 期望参数 1 为 mysqli,在第 7 行的 /home/a8241081/public_html/index.php 中给出 null
我的代码对吗?应该有一个 mysqli_select 语句吗?
<?php
$db_host = "********";
$db_username = "******";
$db_pass = "*******";
$db_name = "********";
mysqli_connect("$db_host","$db_username","$db_pass", "$db_name") or die ("could not connect to mysql");
?>
<?php
session_start();
require_once "scripts/connect_to_mysql.php";
//Build Main Navigation menu and gather page data here
$sqlCommand = "SELECT id, linklabel FROM pages ORDER BY pageorder ASC";
$query = mysqli_query($myConnection,$sqlCommand);
$menuDisplay='';
while ($row=mysqli_fetch_array($query)){
$pid=$row["id"];
$linklabel=$row["linklabel"];
$menuDisplay .='<a href="index.php?pid=' . $pid . '">' . $linklabel . '</a><br/>';
}
mysqli_free_result($query);
//mysqli_close($myConnection);
?>