ERROR WITH MY PHPCODE filtervalues loop (1 Viewer)


Registered User.
Local time
Yesterday, 16:37
Aug 9, 2019
Really would appreciate your support here. I have a project, part of the module in this is to build html form tied to sql database where values can be filter. I am trying to use the php script to get this done. But I have a challenge as some sort of error keep coming up. Code as below:

$filtervalues = $_GET['search'];
$query = "SELECT * FROM users WHERE CONCAT(CabNo, TruckNo, driverSAP) LIKE '%$filtervalues%'";
$query_run = mysqli_query($conn, $query);

From the code, the error throwing up is from the bold script; error is as below:

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\fleetrecords\process.php on line 8
No Record Found

I am pretty new with coding in php, kindly see if you could help out.

Thanks. I will provide any other request

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 00:37
Jul 9, 2003
I note that your post has yet to receive a reply, hence I am taking this opportunity to bump it up the list, and let's see if it gets another look!


Enthusiastic Amateur
Local time
Today, 00:37
Sep 21, 2011


Banishment Pending
Local time
Yesterday, 18:37
May 11, 2011
Never trust yourself to build strings correctly. Just typing in here is challenge enough without making a misspelling. Trying to build one inside a variable making use of other variables is almost impossible.

$query is not a valid query. H'ers the documentation for mysqli_query():

It returns a false (e.g. boolean) value when you pass it an invalid query.

So, you need to find out exactly what is in $query and fix it

Steve R.

Local time
Yesterday, 19:37
Jul 5, 2006
I don't have an actual solution based on the error message you were getting. What I do have is similar code that you could potentially adapt to your situation that may get around the error message. Additionally, the code below uses some PHP functions to "clean-up" the search string for characters that may unexpectedly cause problems. The basic distinction of my code from your code is that I have used a while statement after $rows = mysqli_num_rows($result);

There is also some addtional logic in the code below, that enables an edit feature that I have. That code is probably unnecessary for you. I hope that the sample code will be useful for you.

    $search = ($_REQUEST['AuthorSearch']);
    if (get_magic_quotes_gpc())
            $search = stripslashes($search);
    $search = mysqli_real_escape_string($conn,$search);
    $words = explode(" ", $search);
    $phrase = implode("%' AND AuthorLast LIKE '%", $words);

    $query = "SELECT AuthorIDNUM,AuthorFirst,AuthorLast from tblAuthorList where AuthorFlag AND (AuthorLast like '%$phrase%' OR AuthorFirst like '%$phrase%')
                ORDER BY AuthorLast, AuthorFirst";
    $result =$conn->query($query);
    if (!$result) die($conn->error);

    echo "<h2 style='text-align: center;' >Author Search Results</h2>\n";
    if ($_SESSION['editbol']==intval(1))
        {echo "<h3 style='text-align: center;' >Edit Feature in Effect</h3><br>\n";}

    echo "<div id='show_author_list_table'>";
    echo "<table>";
    $rows = mysqli_num_rows($result);
    while($row=mysqli_fetch_array($result, MYSQLI_ASSOC))
            echo "<tr><td> <a href='index.php?content=show_author_stories&authoridnumvar=$authoridnum &strvar=$search &webtxtvar=$webtext &webvar=$webpage'>$authorfirst $authorlast</a></td></tr>";
    echo "</table>";
    echo "</div>";

Users who are viewing this thread

Top Bottom