?
Solved

MySQL to PHP retrieve

Posted on 2002-04-27
6
Medium Priority
?
202 Views
Last Modified: 2008-03-06
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
Comment
Question by:chromonium
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
lokeshv earned 400 total points
ID: 6973006
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
 

Author Comment

by:chromonium
ID: 6973469
sorry what value should $query hold?

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

Many Thanks

adam
0
 
LVL 4

Expert Comment

by:lokeshv
ID: 6973522
typo error please replace $query from $sql..


Thanks

Lk
0
 
LVL 5

Expert Comment

by:dkjariwala
ID: 6979641
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month15 days, 19 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question