Link to home
Start Free TrialLog in
Avatar of chromonium
chromonium

asked on

MySQL to PHP retrieve

Is it possible, lets say in a database that holds username/password to search for an existing username?

Also how cuold I identify the different records for analysis?


Many Thanks

adam
ASKER CERTIFIED SOLUTION
Avatar of lokeshv
lokeshv

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of chromonium
chromonium

ASKER

sorry what value should $query hold?

I am not advanced at MySQL, so could you please explain,

Many Thanks

adam
typo error please replace $query from $sql..


Thanks

Lk
Why do select all fields ??

Just do like

$query = "select count(username) from TABLENAME where username = '$username' ";

$result = mysql_query($query) or die(mysql_error());
if(mysql_num_rows() > 0 )
   print "User found.";
else
   print "Not found.";

Also beware that this search on username is CASE INSENSITIVE. That is if you search for 'abc' it would even get ABC, aBC,Abc and so on.

Regards,
JD