php - mysql_query() returning false when searching database for a string of text -
my php code executes following query:
$userid = mysql_query("select id users username = '%".$username."%'");
the query being returned false. know because $userid contains boolean value after query executed.
i tried perform query in phpmyadmin , noticed query works if encapsulate string in quotations, don't think can in php code.
is syntax wrong? can give...
update: when echo $userid after query executed following output:
resource id #5resource id #6
which tells me query executing successfully, not processing results correctly.
you need use like
operator:
$userid = mysql_query("select id users username '%".$username."%'");
for completeness sake here link official documentation
if want exact match should use =
operator then.
$userid = mysql_query("select id users username = '".$username."'");
do know if value being passed in $username
variable valid?
Comments
Post a Comment