1,105,585 Community Members

mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in

Member Avatar
Shalomd
Light Poster
38 posts since Feb 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Dear Friends,
Help me to fix this..
Error Message : mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in
Code is,

<?php
$database=$diocese;
$table=$category;


//capture search term and remove spaces at its both ends if the is any
$searchTerm = trim($_GET['query']);


//check whether the name parsed is empty
if($searchTerm == "")
{
    echo "Enter name you are searching for.";
    exit();
}

//database connection info
$host = "localhost"; //server
$db = $_GET['db']; //database name
$user = "root"; //dabases user name
$pwd = ""; //password
$table = $_GET['fundcat'];

//connecting to server and creating link to database
$link = mysqli_connect($host, $user, $pwd, $db);

//MYSQL search statement
$query = "SELECT * FROM '%$table%' WHERE Fund Name LIKE '%$searchTerm%'";

$results = mysqli_query($link, $query);

/* check whethere there were matching records in the table
by counting the number of results returned */
if(mysqli_num_rows($results) >= 1)
{
    $output = "";
    while($row = mysqli_fetch_array($results))
    {
        echo '<table>';
LastMitch
Deleted Member
 
1
 

@Shalomd

mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in

There's something wrong with this query:

$query = "SELECT * FROM '%$table%' WHERE Fund Name LIKE '%$searchTerm%'";

Do you have a $table & $searchTerm in your table or database?

Member Avatar
Shalomd
Light Poster
38 posts since Feb 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Yes Have

Member Avatar
pritaeas
mod_pritaeas
11,315 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
1
 

What are you trying to accomplish?

This could work (depending on your table structure):

$query = "SELECT * FROM `$table` WHERE `Fund Name` LIKE '%$searchTerm%'";
Question Answered as of 1 Year Ago by pritaeas and LastMitch
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article