Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » About to pull my hair out?
Closed Thread
Old 09-09-2006, 03:05 AM   #1 (permalink)
 
Super Techie

Join Date: Apr 2006

Posts: 454

lazer_viking

Default About to pull my hair out?

Ack! its 12:00am and my eyes are slamming shut. i had my first go at trying to learn php, and i think i learned a lot by following along in this login system tutorial. i learned how to do all the things in the code below. but what it reaaaaalllllyyyyyy irritating me is this error when i try to execute the script. it says "Parse error: syntax error, unexpected '{' in /var/www/loginsys/register.php on line 42"

i have marked line number 42 with this: ">>>> 42 >>>>"

by the way this isnt a site for gangsters or anything lol, i just used some funny lines (that i thought were funny anyway) to make things more interesting lol

PHP Code:
<?
//DB connector script
include 'db.php';

//Information collecter
$first_name $_POST['first_name'];
$last_name $_POST['last_name'];
$email_address $_POST['email_address'];
$username $_POST['username'];
$info $_POST['info'];

//Escaped character remover
$first_name stripslashes($first_name);
$last_name stripslashes($last_name);
$email_address stripslashes($email_address);
$username stripslashes($username);
$info stripslashes($info);

//Error checker and debugger
if((!$first_name) || (!$email_address) || (!$username)){
  echo 
"You didn\'t completely fill out your stuff. REDO IT!!! 
"
;
  if(!
$first_name){
    echo 
"You need to fill out your first name homie. I needa know what to call ya! 
"
;
  }
  if(!
$email_address){
    echo 
"I\'m gonna need your email address. How else am I going to contact you with your password!?!? jeez! 
"
;
  }
  if(!
$username){
    echo 
"You need something to log in with... doh! 
"
;
  }
  include 
'index.html';
  exit();
}

//Duplicate entry checker
$sql_email_check mysql_query("SELECT email_address FROM users WHERE email_address='$email_address'");
$sql_username_check mysql_query("SELECT username FROM ysers WHERE username='$username'");

$email_check mysql_num_rows($sql_email_check);
$username_check mysql_num_rows($sql_username_check);

[
color=red]>>>> 42 >>>>[/color]if(($email_check || ($username_check 0)) {
  echo 
"Let\'s check to see if your email address or username is already in use 
"
;
  if(
$email_check 0){
    echo 
"Looks like you\'ve already registered this email address here. Don\'t know what to tell ya lol... get a new email address or remember your old password! 
"
;
  unset(
$email_address);
  }
  if(
$username_check 0){
    echo 
"Someone done lifted yo username! homie, you gosta try da add some numbuhs afta it or somethin\'!!";
  unset(
$username);
  }
  include 
'index.html';
  exit();
}

//This is our nifty random password generater!
function makeRandomPassword() {
  
$salt "abcdefghijklmnopqrstuvwxyz1234567890";
  
srand((double)microtime()*1000000);
    
$i 0;
    while 
$i <= 7) {
      
$num rand() % 33;
      
$tmp substr($salt$num1);
      
$pass $pass $tmp;
      
$i++;
    }
    return 
$pass;
}

$random_password makeRandomPassword();

$db_password md5($random_password);

//Put it in the sql table!
$info2 htmlspecialcharacters($info);
$sql mysql_query("INSERT INTO users (first_name, last_name, email_address, username, password, info, signup_date)
  VALUES('$first_name', '$last_name', '$email_address', '$username', '$password', '$info', now())"
) or die (mysql_error());

if (!
$sql){
  echo 
'Our bad, our system is broke. You\'ve basically wasted your time. Sorry';
} else {
  
$userid mysql_insert_id();

//Lets send an email to our new registrant. woot.
$subject "Registration at sapphireconcepts.net!";
$message "Dear $first_name,
You are the pwnage for registering. But there IS one more thing you gosta do homie. Just click this link to activate your account: [url]http://67.170.117.94/loginsys/activate.php?id=[/url]$userid&code=$db_password

Once you do all that stuff, you can log in with this stuff:
Username: $username
Password: $random_password
That password is pretty goofy lookin but yknow, you can change it. If it wasnt this way, then ppl could haxzorz j00!!

Appreciate it homie,
sapphireconcepts staff

This aint a real peep right here, so dont respond cause you aint gonna get an answer!"
;

mail($email_address$subject$message,
  
"From: sapphireconcepts  <laser.viking@gmail.com>\n
  X-Mailer: PHP/" 
phpversion());
echo 
'Aight, I hooked you up with all yo account information at the email address you told me, so it better not be fake! If it iz you betta back yoself up and fix it!';
}

?>

__________________
[CPU: e6600 @ 3300 MHz] // [MB: ASUS P5N-E SLi] // [RAM: Patriot 'eased latency' PC2-6400 @ DDR800 5-4-4-12-2T] // [GPU: 8800GTX @ 650/1000/1600 (volt modded)] // [HDD: 2x Cavier 500GiB stripe] // [Chassis: Thermaltake Armor VA8000 (black)] // [PSU: Aspire(Apevia) 680w] // [OS: Windows 7 Ultimate x64][Cooling: water cooled GPU and CPU]

3DMark06: ~11600
3DMark Vantage: 5873
lazer_viking is offline  
Old 09-09-2006, 11:22 AM   #2 (permalink)
 
Monster Techie

Join Date: May 2004

Location: /usr/root/mn/us

Posts: 1,121

bla!! is on a distinguished road

Default

You're missing a closing parenthese

if(($email_check > 0 ) || ($username_check > 0)) {
__________________
<br>
Its a frigging Laptop, not a Labtop!!!!
bla!! is offline  
Old 09-09-2006, 12:19 PM   #3 (permalink)
 
Super Techie

Join Date: Apr 2006

Posts: 454

lazer_viking

Default

omg lol *doh* thanks it was just getting late last night i think. i wasnt thinking clearly. thanks again
__________________
[CPU: e6600 @ 3300 MHz] // [MB: ASUS P5N-E SLi] // [RAM: Patriot 'eased latency' PC2-6400 @ DDR800 5-4-4-12-2T] // [GPU: 8800GTX @ 650/1000/1600 (volt modded)] // [HDD: 2x Cavier 500GiB stripe] // [Chassis: Thermaltake Armor VA8000 (black)] // [PSU: Aspire(Apevia) 680w] // [OS: Windows 7 Ultimate x64][Cooling: water cooled GPU and CPU]

3DMark06: ~11600
3DMark Vantage: 5873
lazer_viking is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On