• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

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
0
chromonium
Asked:
chromonium
  • 2
1 Solution
 
lokeshvCommented:
yeah it is ..

somehting like this...

$sql="select * from ur_table where username='$username'";

$qid=mysql_query($query);

if(mysql_num_rows($qid)==1){
return 1;
}
else{
return 0;
}

Hope this helps....

Lk
0
 
chromoniumAuthor Commented:
sorry what value should $query hold?

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

Many Thanks

adam
0
 
lokeshvCommented:
typo error please replace $query from $sql..


Thanks

Lk
0
 
dkjariwalaCommented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now