-1

我希望将数据提取到 html 表中。

编辑:

  <?php       
    mysql_connect("localhost","root","");
    mysql_select_db("music_world");
    $result = mysql_query("SELECT * FROM all_songs");
    echo "<table border='1'>";
    echo "<tr> <th>Serial No.</th> <th>Title</th>  </tr>";
    while($row = mysql_fatch_array( $result )) {
            echo "<tr><td>".$row['id']."</td><td>". $row['title']."</td></tr>"; 
    } 
    echo "</table>";
 ?>

我不知道问题出在哪里。这段代码应该可以工作,但事实并非如此。为什么我会收到此错误:

 Fatal error: Call to undefined function mysql_fatch_array() in D:\xampp\htdocs\one.php on line 7 
4

2 回答 2

4
   while($row = mysql_fetch_array( $result )) {
                     ^---missing i

您不能混合使用 mysql 和 mysqli 库。它们不能互操作。

于 2013-07-26T20:12:56.797 回答
2

您正在混合两个完全不同的库!

http://php.net/manual/en/book.mysqli.php
http://php.net/manual/en/ref.mysql.php

您正在尝试使用已弃用的 MySQLi 函数别名mysqli_connect和旧 MySQL 库mysqli_querymysql_fetch_array函数。

推荐使用 MySQLi。看:

http://www.php.net/manual/en/mysqli.construct.php
http://www.php.net/manual/en/mysqli.query.php

于 2013-07-26T20:12:33.810 回答