Jump to content

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
I normally set this into the database that the username has to be an unique value
Also silentwf I do not recomment using:

[code]
<?php
if !isset($checkUsername[...
// Instead use
if (!in_array($username, $checkUsername)) { ...
?>
[/code]
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]
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.