0

I keeep getting this error: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Projeto\search.php on line 7

How do I fix?

if (isset($_POST['action']) == 'Search') {
    $search = $_POST['search'];

    require 'conf/connection.php';

    $selection = mysql_query("SELECT * FROM users WHERE name '%$search%'");
    $number = mysql_num_rows(mysql_query("SELECT * FROM users WHERE name '%$search%'"));
}
2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by richaell
0
$r = mysql_query("SELECT * FROM users WHERE name '%$search%'");
$number = mysql_num_rows($r);

You need to clean the input:

$search = mysql_real_escape_string($_POST['search']);

but this needs to come after the connection or you'll get an error.

Edited by diafol: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.