Is this an unique user name???
| From: | Alex Davis | Date: | Tue, 18 Feb 2003 12:00:06 +0000 |
| Subject: | Is this an unique user name??? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-135982@lists.php.net to get a copy of this message | ||
Ok... I am trying to have this registration page search a table in a db to find out if the user name supplied is unique. Here is the syntax that I used but it does not seem to work:
<?
.....
$var_UserName = addslashes($_POST['User_Name']);
.....
$query = "SELECT * FROM company_info WHERE UserName = '";
$query .= $var_UserName."'";
$result = mysql_query($query);
// This is where the problem come in... I tried these two options, both
// failed.
//Opt1
$num_results = mysql_num_rows($result);
if( $num_results > 0 ) //this user name is not unique
{ // exec the error methods.... }
else
{ // add record to db }
//Opt2
if( $results ) // To my knowlegde ;) this would be true if $results > 0
{ // exec error }
else
{ // add record }
.....
?>
Is there something that I am missing? Or actually doing wrong? If anybody would need to see the whole script I would be glad to supply on demand.
Thank for your time,
-Alex