嗨,你能幫我解決這個錯誤嗎?錯誤mysql_fetch_array()期望參數1是資源
「警告:mysql_fetch_array()期望參數1是資源, 對象在第31行的」blablabla「中給出。
我已經嘗試了很多我找到的解決方案,但它仍然導致我出現此錯誤。
<html>
<head>
<title>
Autores
</title>
</head>
<body>
<?php
$link = mysqli_connect("", "", "", "");
if($link === false){
die("ERRRO: Não foi possivel a conexão com a base de dados. " . mysqli_connect_error());
}
$sql = 'SELECT * FROM autores';
$result = mysqli_query($link, $sql) or die($sql."<br/><br/>".mysql_error());
echo "<p><b>Ver todos</b> | <a href='view-paginated.php?page=1'>Ver por página</a></p>";
echo "<table border='1' cellpadding='10'>";
echo "<tr> <th>ID</th> <th>Autor</th><th></th> <th></th></tr>";
while($row = mysqli_fetch_array($result)) {
// echo out the contents of each row into a table
echo "<tr>";
echo '<td>' . $row['a_id'] . '</td>';
echo '<td>' . $row['a_nome'] . '</td>';
echo '<td><a href="edit.php?id=' . $row['id'] . '">Edit</a></td>';
echo '<td><a href="delete.php?id=' . $row['id'] . '">Delete</a></td>';
echo "</tr>";
}
// close table>
echo "</table>";
?>
<p>
<a href="new.php">Add a new record</a>
</p>
</body>
</html>
感謝,
貢薩洛·皮尼奧
**不共用數據庫ID和密碼!** –
認真......發佈連接數據? – donald123
您混合使用'mysqli _...()'和'mysql _...()'函數。這是沒有意義的。 – arkascha