-2

i am getting this error and i can't find boolen. Can somebody help please?

if(isset($_POST['search_term'])){
    $search_term = mysql_real_escape_string(htmlentities($_POST['search_term']));

    if (!empty($search_term)){
        $search = mysql_query ("SELECT `username` FROM  `users ` WHERE  `users` LIKE '%search_term%'");

        while ($results_row = mysql_fetch_assoc($search)){
            echo '<p>',$results_row['username'],'</p>';
        }
    }
}
?>
CroStorm99
  • 152
  • 1
  • 3
  • 11
  • `mysql_error()` will tell you about an unknown table name. Plain SQL escaping is insufficient for LIKE constraints, btw. – mario Jan 24 '15 at 16:40

1 Answers1

0

This part of your script '%search_term%' is missing the $

change that to '%$search_term%'

and remove the space in your table name

`users `
      ^

as Mario stated. You will have an unknown table name. Kudos to Mario.

While you're at it, switch to mysqli_ or PDO. You'll eventually have to switch; it's deprecated and will be removed in future PHP releases.

Also add or die(mysql_error()) to mysql_query() to catch errors.

Funk Forty Niner
  • 74,372
  • 15
  • 66
  • 132
  • @IvanGorički You're welcome Ivan. Consider accepting the answer. Here's how http://meta.stackexchange.com/a/5235/ then come back and do the same thing. *Cheers* – Funk Forty Niner Jan 24 '15 at 16:41