mjohnson025 Posted April 29, 2008 Share Posted April 29, 2008 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 More sharing options...
PFMaBiSmAd Posted April 29, 2008 Share Posted April 29, 2008 $row = $DBconnect->fetch_row($result); should be - $row = $DBconnect->fetch_row(); Link to comment https://forums.phpfreaks.com/topic/103481-solved-mysqli_fetch_row-error/#findComment-529877 Share on other sites More sharing options...
mjohnson025 Posted April 29, 2008 Author Share Posted April 29, 2008 thanks, I also figured out that $DBconnect->fetch_row() should have been $result->fetch_row() since it was the newest object. Thanks for your help! Mike Link to comment https://forums.phpfreaks.com/topic/103481-solved-mysqli_fetch_row-error/#findComment-529902 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.