這是我的PHP代碼:PHP MySQL的警告:mysqli_fetch_array()預計參數1被mysqli_result
<html>
<head>
<title>SQL DB Management</title>
</head>
<body>
<h1>MySqlAdmin</h1>
<table>
<tr>
<th><!--Heading 1--></th>
<th><!--Heading 2--></th>
<th><!--Leave it blank--></th>
</tr>
<?php
$db_host = "mysql.freehostingnoads.net";
$db_username = "";
$db_password = "";
$db_name = "";
$db_table = "";
$db = mysqli_connect($db_host, $db_username, $db_password, $db_name);
if (mysqli_connect_errno()){die("Failed to connect to MySQL: " . mysql_connect_error());}
$content = mysqli_query($db,"SELECT * FROM " . $db_table);
while($line = mysqli_fetch_array($content)){
echo("<tr>");
echo("<td>" . $line['c1'] . "</td>");
echo("<td>" . $line['c2'] . "</td>");
#delete button
echo("<td><form action='del.php' method='GET'><input type='text' name='c1' value='" . $line['c1'] . "' /><input type='text' name='c2' value='" . $line['c2'] . "' /><input type='button' value='DEL' /></form></td>");
echo("</tr>");
}
?>
</body>
</html>
而直接跳過讀取<head>
,這是我收到的警告:
警告:mysqli_fetch_array()預計參數1是mysqli_result,布爾在/home/u273577101/public_html/index.php給出關於線23
我有海但卻無法找到答案。這裏有什麼問題?
我猜,沒有連接錯誤。它似乎沒有給我任何關於連接的錯誤消息。
您是否知道'$ db_table'在這段代碼中被評估爲空字符串? – bruchowski
通過回顯查詢來檢查查詢是否正常工作。 – Jenz
'$ db_table =「」;'表名是空白的,並且在右邊的列中讀取類似問題的loooooooooooong列表** RELATED ** –