Search
Left Quote    Every day I get up and look through the Forbes list of the richest people in America. If I
- Robert Orben    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: Error in username and email check
  This user is offline  Smeagol3
  Subject: "Error in username and email check" Posted: @ 1:09 am on May 20 2008   
Member #: 676
Rank: User - (7)
Since: 04/29/08
Posts: 7

I'm using a combination of a few different member systems, and this is in register.php, where I compare the entered info to the database info to make sure the username and email aren't taken yet.


Code:
$sql_username_ check = mysql_query(&qu ot;SELECT username FROM member_info WHERE username='$user name'";
$sql_email_chec k = mysql_query(&qu ot;SELECT user_email FROM member_info WHERE user_email='$us er_email'"< img src=http://www. allsyntax.com/f orums/images/sm ilies/wink.gif border=0>;

$username_check = mysql_num_rows( $sql_username_c heck);
$email_check = mysql_num_rows( $sql_email_chec k);
if(($username_c heck > 0)) || ($email_check > 0)) <--This is line 46!
{
echo "Please fix the following errors: <br />";
if($username_c heck > 0{
echo "The username you have selected has already been taken. Please choose a different username.<br />";
unset($userna me);
}
if($email_chec k > 0{
echo "The email you have selected has already been taken. Please choose a different email.<br />";
unset($user_e mail);
include 'register_form. html';
exit();
}
}



I get this error.
 My Website said...
< i>Parse error: syntax error, unexpected T_BOOLEAN_OR in /home2/faithnet /public_html/re gister.php on line 46

Any ideas?

Thanks,
Smeagol3

Edited at 01:20:22 am on 05/20/08


    Viewed: 6,732 Times | Reply to This | To top
  This user is offline  David1159
  Subject: "re: Error in username and email che..." Posted: @ 6:37 am on May 20 2008    

Member #: 526
Rank: User - (81)
Since: 12/27/07
Posts: 81
From: usa

One thing, I believe this is poorly written IMO.

If your trying to see if the username and user email is already taken you can simply do this.


Code:


$sql_username_c heck = mysql_query(&q uot;SELECT username FROM member_info WHERE username='$use rname' AND user_email='$u ser_email'&qu ot;);
if(!$sql_userna me_check) die('error');


what I have shown is a simplified version, taking about 10-15 lines of code to half of that.

Now I see what the problem is in your code.

You have this...

Code:
if(($username_ check > 0)) || ($email_check > 0))


Try this...

Code:
if($username_c heck > 0 || $email_check > 0)



The smallest thing as a (( or ' or ; or damn anything will cause a problem. Like I said this was a tad poorly written.

Look into the membership tut bs0d has in the tutorial section here.




Coding is simply CST... Combining $hit Together. We make different $hit to run in unison correctly.

    Viewed: 6,720 Times | Reply to This | To top
  This user is offline  Smeagol3
  Subject: "re: Error in username and email che..." Posted: @ 10:07 pm on May 20 2008    
Member #: 676
Rank: User - (7)
Since: 04/29/08
Posts: 7

That fixed it. Thanks.




    Viewed: 6,690 Times | Reply to This | To top
  This user is offline  David1159
  Subject: "re: Error in username and email che..." Posted: @ 7:17 am on May 22 2008    

Member #: 526
Rank: User - (81)
Since: 12/27/07
Posts: 81
From: usa

Your welcome . Keep in mind.

Like I said, I don't know how good that coding your using is. From what you posted it can be simplified down a lot. My guess is a lot of the code is written that way, you can make your site half of that and use less bandwidth if written properly. Which saves you more money and will lower the waiting time for users on loading.




Coding is simply CST... Combining $hit Together. We make different $hit to run in unison correctly.

    Viewed: 6,667 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank