php - strpos() function on mysql_fetch_array -


i have code fetching information mysql database in php , want compare $username variable information strpos() function...but doesn't work.... can do?

 $username = $_get['username'];  $connection = new db_database();  $res = $connection->select();  if ($res) {  $output = "";  while ($row = mysql_fetch_array($res)) {     if (strpos((string)$row['username'], $username)) {         $output.=" " . $row["username"] . " ";     }   echo $output; 

i 'm not sure why using strpos instead of straight comparison ==, code not work correctly if $row['username'] == $username.

the reason in case strpos return 0, evaluates false -- see giant red warning on documentation page.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -