我定義我$link
在database.php
:mysqli_query錯誤
$link=mysqli_connect("localhost","root","","oop");
if (mysqli_connect_errno($link))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
後,我包括這在我的header.php
:
include "../includes/database.php";
然後我用它在mysqli_query
電話:
$result = mysqli_query($link, "SELECT * FROM Menu")
or die(mysql_error());
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
echo '<div id= menulist>';
echo '<div class="menu" id="menu-'.$row['menu_id'].'">';
echo $row['menu_name'] . " - ". $row['menu_weight']
. "<a class='delete' href='?delete=".$row['menu_id']
."'><img src='images/delete.png' /></a>";
echo '</div>';
發生以下錯誤:
警告:mysqli_query()預計參數1是mysqli的,在/Applications/XAMPP/xamppfiles/htdocs/www/oop/admin/menu_class.php空給出線39
做什麼我做錯了?
可能重複[我應該將我的$ mysqli變量傳遞給每個函數?](http://stackoverflow.com/questions/14016462/should-i-pass-my-mysqli-可變的每個功能) – 2016-06-16 22:47:13