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
https://forums.phpfreaks.com/topic/42949-editing-account-problem/
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.