tautuxs9 Posted May 22, 2019 Share Posted May 22, 2019 Hey guys. I need help with the program. I get error Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\index.php on line 15 Here is my code: 1st file. <?php include_once 'includes/DuombazesInfo.php' ?> <!DOCTYPE html> <html> <head> <title></title> </head> <body> <?php $sql = "SELECT * FROM vartotojai"; $result = mysqli_query($con, $sql); $resultCheck = mysqli_num_rows($result); if ($resultCheck > 0) { while ($row = mysqli_fetch_assoc($result)) { echo $row['vartotojas_vardas']; } } ?> </body> </html> 2nd file. <?php $dbServername = "localhost"; $dbUsername = "root"; $dbPassword = ""; $dbName = "duombaze"; $con = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbPassword); Link to comment Share on other sites More sharing options...
tautuxs9 Posted May 22, 2019 Author Share Posted May 22, 2019 23 minutes ago, tautuxs9 said: Hey guys. I need help with the program. I get error Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\index.php on line 15 Here is my code: 1st file. <?php include_once 'includes/DuombazesInfo.php' ?> <!DOCTYPE html> <html> <head> <title></title> </head> <body> <?php $sql = "SELECT * FROM vartotojai"; $result = mysqli_query($con, $sql); $resultCheck = mysqli_num_rows($result); if ($resultCheck > 0) { while ($row = mysqli_fetch_assoc($result)) { echo $row['vartotojas_vardas']; } } ?> </body> </html> 2nd file. <?php $dbServername = "localhost"; $dbUsername = "root"; $dbPassword = ""; $dbName = "duombaze"; $con = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbPassword); 23 minutes ago, tautuxs9 said: Hey guys. I need help with the program. I get error Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\index.php on line 15 Here is my code: 1st file. <?php include_once 'includes/DuombazesInfo.php' ?> <!DOCTYPE html> <html> <head> <title></title> </head> <body> <?php $sql = "SELECT * FROM vartotojai"; $result = mysqli_query($con, $sql); $resultCheck = mysqli_num_rows($result); if ($resultCheck > 0) { while ($row = mysqli_fetch_assoc($result)) { echo $row['vartotojas_vardas']; } } ?> </body> </html> 2nd file. <?php $dbServername = "localhost"; $dbUsername = "root"; $dbPassword = ""; $dbName = "duombaze"; $con = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbPassword); Don't need no more. Fixed myself Link to comment Share on other sites More sharing options...
Larry Posted May 22, 2019 Share Posted May 22, 2019 This happens when there's an error with your query (i.e., it causes a MySQL error; it doesn't return 0 or more results). You should apply the standard MySQL debugging techniques: print out the query and run it using another interface or just invoke mysqli_error() directly. Link to comment Share on other sites More sharing options...
Recommended Posts