php - %% signs in like syntax in mysql doesn't work when there is an exact match -
this question has answer here:
my question simple didn't find question or answer this.i mean not solution case. here code.
$characters = $_get["search"]; $characters2 = "%". $characters . "%" ; $statement = $connection->prepare( "select name,username users 'name' :username or 'username' :username"); $statement->bindparam(':username', $characters2, pdo::param_str); $statement->execute();
problem if have david in name column in database , $_get["search"] "davi" or "david" couldn't find david's row.
returns empty.
you're comparing string 'name' , input user 'david'. sql, need put name of column, in case name. same thing username
thus,
$statement = $connection->prepare( "select name,username users name :username or username :username");
without quotes around name , username work
wiki
Comments
Post a Comment