A PHP error for no real reason?

Discussion in 'PHP' started by Matt Ridge, Sep 23, 2011.

  1. #1
    Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /kaboomlabs.com/index.php on line 24


    This is the error I get. Line 24 is while ($row = mysqli_fetch_array($data)) { ... the database is filled with the correct info. So I'm lost upon why this is happening...


    Any ideas would be appreciated.


    All I can think of is the { is not suppose to be there.


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>Guitar Wars - High Scores</title>
      <link rel="stylesheet" type="text/css" href="style.css" />
    </head>
    <body>
      <h2>Guitar Wars - High Scores</h2>
      <p>Welcome, Guitar Warrior, do you have what it takes to crack the high score list? If so, just <a href="addscore.php">add your own score</a>.</p>
      <hr />
    
    
    <?php
      // Connect to the database 
      $dbc = mysqli_connect('localhost', 'pawz_PDI', 'xxxxxx', 'pawz_PDI');
    
    
      // Retrieve the score data from MySQL
      $query = "SELECT * FROM guitarwars";
      $data = mysqli_query($dbc, $query);
    
    
      // Loop through the array of score data, formatting it as HTML 
      echo '<table>';
        while ($row = mysqli_fetch_array($data)) {
        // Display the score data
        echo '<tr><td class="scoreinfo">';
        echo '<span class="score">' . $row['score'] . '</span><br />';
        echo '<strong>Name:</strong> ' . $row['name'] . '<br />';
        echo '<strong>Date:</strong> ' . $row['date'] . '</td></tr>';
      }
      echo '</table>';
    
    
      mysqli_close($dbc);
    ?>
    
    
    </body> 
    </html>
    Code (markup):
     
    Solved! View solution.
    Matt Ridge, Sep 23, 2011 IP
  2. #2
    add or die(mysqli_error()) to your mysqli_query, see if your query is ok first, maybe misspelled table name
     
    som3on3, Sep 23, 2011 IP
  3. Matt Ridge

    Matt Ridge Peon

    Messages:
    166
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #3
    Sad thing this is from a book...

    and the error is the same, there is no further explination...
     
    Matt Ridge, Sep 23, 2011 IP
  4. Matt Ridge

    Matt Ridge Peon

    Messages:
    166
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #4
    Got it working... it was a server issue.
     
    Matt Ridge, Sep 23, 2011 IP
  5. fiksfarenet

    fiksfarenet Member

    Messages:
    137
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #5
    host server problem
     
    fiksfarenet, Oct 2, 2011 IP