Jump to content
Larry Ullman's Book Forums

Recommended Posts

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

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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...