Solved

MySQL to PHP retrieve

Posted on 2002-04-27
6
193 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
6 Comments
 
LVL 4

Accepted Solution

by:
lokeshv earned 100 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
echo button 13 47
populate dynamic drop down from a csv 3 39
Not needed 13 57
How to install phpMyAdmin on AWS Elastic Beanstalk 2 36
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

762 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now