-1

I want the data to be fetched into a html table.

Edited:

  <?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>";
 ?>

I don't know where is the problem. this code is suppose to work but its not. why am I getting this error:

 Fatal error: Call to undefined function mysql_fatch_array() in D:\xampp\htdocs\one.php on line 7 
Giliweed
  • 4,865
  • 7
  • 25
  • 35
  • 1
    `mysqli_connect_errno` doesn't require a parameter. It's useless at best to pass `$con` as a parameter. – GolezTrol Jul 26 '13 at 20:13

2 Answers2

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

you cannot mix the mysql and mysqli libraries. They are NOT inter-operable.

Marc B
  • 348,685
  • 41
  • 398
  • 480
2

You are mixing two completely different libraries!

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

You're attempting to use the deprecated MySQLi function aliases mysqli_connect and mysqli_query with the mysql_fetch_array function of the older MySQL library.

MySQLi is recommended. See:

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

Brian Lacy
  • 18,358
  • 10
  • 51
  • 73
  • 1
    Good spot, although I suspect it is a typo rather than the actual belief that the two are interoperable. – GolezTrol Jul 26 '13 at 20:16
  • That may be, but the interesting part is that because those two functions actually exist (as aliases of the MySQLi methods), the OP is getting a potentially-confusing semantic error instead of something obvious like a "function not defined" message. – Brian Lacy Jul 26 '13 at 20:19