Solved

MySQL to PHP retrieve

Posted on 2002-04-27
6
196 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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.

770 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