Jump to content

Editing Account Problem


lJesterl

Recommended Posts

Im working on a script for users to edit there account here is what im using on the checking to make sure the username or the email doesnt already exist. However its detecting there username and email if they leave it the same. Here is a snippet of code that I am using

 

$status = "OK";
$msg="";


// if userid is less than 3 char then status is not ok
if(!isset($alias) or strlen($alias) <3){
$msg=$msg."Userame should be =3 or more than 3 char length<BR>";
$status= "NOTOK";}

if(mysql_num_rows(mysql_query("SELECT alias FROM validate WHERE alias = '$alias'"))){
$msg=$msg."Username already exists. Please try another one<BR>";
$status= "NOTOK";}					

if(mysql_num_rows(mysql_query("SELECT email FROM validate WHERE email = '$email'"))){
$msg=$msg."This Email is already Registered<BR>";
$status= "NOTOK";}				

if(mysql_num_rows(mysql_query("SELECT alias FROM users WHERE alias = '$alias'"))){
$msg=$msg."Username already exists. Please try another one<BR>";
$status= "NOTOK";}					

if(mysql_num_rows(mysql_query("SELECT email FROM users WHERE email = '$email'"))){
$msg=$msg."This Email is already Registered<BR>";
$status= "NOTOK";}	


Link to comment
Share on other sites

And you might want to change the query's.

mysql_num_rows(mysql_query("SELECT alias FROM validate WHERE alias = '$alias'"))

That is not gonna help the script really....

 

 

Never enclose one MySQL function inside another like that. As already explained, a query could return an error and a valid results resource won't exist (or be returned). This would then cause the outer function to fail with a "not a valid MySQL result resource" message

 

Read http://www.phpfreaks.com/forums/index.php/topic,95443.0.html

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.