Jump to content

Checking duplicate user in a DATABASE?


bilis_money

Recommended Posts

Hello bilis
Anyways, I ran into this problem myself, but now I can provide you with the answer  :D
[code]
$query  = "SELECT username FROM users WHERE username='$username'";
$result = mysql_query($query);
$checkUsername = mysql_fetch_array($result);

if!isset($checkUsername['username']){ //if the username is not taken
//do something
} else {
//report error
}
[/code]
Hope this helps
Link to comment
Share on other sites

"[font=Verdana][u][b]i would like to check a user duplicate inside a MySQL database.[/b][/u][/font]"


Guys , what if i want to get count +  user name that have duplcate entry through a sql  query with out providin any $username

Link to comment
Share on other sites

xec now your obsetly making it difficult, you need the where clausule otherwise you can not check where something is equal/duplicate

[code]
$query = "SELECT `username`, COUNT(`username`) AS `DuplicateEntries` FROM `users` WHERE `username`='$username'";// will possibly not work... therefore rather use:
$Query = mysql_query("SELECT `username` FROM `users` WHERE `username`='$username'");
$Rows = count(mysql_fetch_array($Query));
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.