pdo - PHP - in_array isn't finding my value -


this question has answer here:

i'm newb , got problem in_array...

so array $allusers (received sql-query usernames)

    array (     [0] => array         (             [name] => test         )      [1] => array         (             [name] => test2         )      [2] => array         (             [name] => admin         )      [3] => array         (             [name] => kingchräbi         ) 

now if new member wants register, want check in array if it's existent:

if(!in_array($username,$allusers)){.... 

eventhough when $username not in $allusers .... it's skipping else if user existing :(

$username set before

$username = $_post['name']; 

and working should (i can echo without problem, test or test2 without whitespace or anything)

i looked around alot, can't find problem here... please me?

thanks

although question quite silly, have realize array working with, quick solution, based on pdo tag, follows: instead of fetchall() use fetchall(pdo::fetch_column)

or, rather need learn sql well, , find users not means of selecting them database makes no sense, asking database find user you

$stm = $pdo->prepare("select * table name=?"); $stm->execute(array($_post['name'])); $user = $stm->fetch();  if ($user) { // <---here go 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -