Jump to content

[SOLVED] mysqli_fetch_row() error


mjohnson025

Recommended Posts

Greetings all-

 

I keep getting a fatal error: call to undefined method for mysqli::fetch_row() on line 15. Can anyone help me figure out what's wrong?

 

Any help will be appreciated!

 

Thanks,

Mike

<?php 
  $table_contents = "";
  $DBconnect =  @new mysqli("localhost", "root", "gotham");  
     if (mysqli_connect_errno())
    die("<p>Unable to connect to the server." . "Error Code " . mysqli_connect_errno() . ": " . mysqli_connect_error()) . "</p>";
$DBName = "cwb208";
@$DBconnect->select_db($DBName)
     or die("<p>Unable to select the database.</p>" . "<p>Error Code " . mysqli_errno($DBconnect) . ": " . mysqli_error($DBconnect)) . 
 "</p>";
  $sql = "select state_code, count(*) from regusers group by state_code order by 2 ";  
  $result = $DBconnect->query($sql)
     //or die("<p>Unable to execute the query.</p>" . "<p>Error Code " . $DBconnect->errno . ": " . $DBconnect->error) . "</p>";
     
  or die ("MySQL Error! SQL: $sql, Error: " . mysqli_error($DBconnect));
  $row = $DBconnect->fetch_row($result);
  //or die("<p>Unable to select the database.</p>" . "<p>Error Code " . mysqli_errno($DBconnect) . ": " . mysqli_error($DBconnect)) . 
// "</p>";
  while ($result) {
    $table_contents .= "<tr>" .
                       "<td>" . trim($row[0]) . "</td>" .
                       "<td>" . trim($row[1]) . "</td>" .
                       "</tr>";
    $row = $DBconnect->fetch_row($result);
  }
  $DBconnect->close();
?>
<html>
<head>
<title>CP11 Summary Report</title>
</head>
<body>
<h2>Counts By State</h2>
<table border="1" summary="">
<tr>
	<td>US State</td>
	<td>Count</td>
</tr>
<?php echo $table_contents; ?>
</table>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/103481-solved-mysqli_fetch_row-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.