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

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -