-3

我正在尝试使用这个基于网络的词典进行学习,但我在从数据库中获取结果和显示单词方面遇到了一些问题。它显示错误消息为“mysql_fetch_row() 期望参数 1 是资源,在第 14 行的 C:\wamp\www\Dictionary\home.php 中给出的布尔值”下面是代码..请帮助

<?php
$con=mysqli_connect("localhost","dictionary");

// Check connection
if (mysqli_connect_errno($con))
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
?>
<table>
<?php
$result=mysql_query("select word from word_table order by asc");
//$row = mysql_query($result);
while($word = mysql_fetch_row($result))
{
echo("<tr><td>$word[0]</td></tr>");
}
?>
4

1 回答 1

2

你必须在mysqli这里使用,因为你使用了mysqlidor DB连接

$result=mysqli_query($con,"select word from word_table order by asc");

while($word = mysqli_fetch_row($result))

mysqli_connect需要 4 个参数用于 DB 连接

$con=mysqli_connect("localhost","dictionary","your_password","db_name");

编辑

$result=mysqli_query($con,"select word from word_table order by column_name asc");
于 2013-06-10T04:52:53.420 回答