Parse error: syntax error, unexpected '(',

Discussion in 'PHP' started by yusiyuseff, Feb 6, 2009.

  1. #1
    i am trying to intall a script and i get this erro can some one please tellme how to fix it thank you in advance


    Parse error: syntax error, unexpected '(', expecting T_CLASS in /register.php on line 18
    <?
    
    require('config.php');
    require('inc/main.inc.php');
    
    $action = $_REQUEST['action'];
    
    include('templates/header.php');
    
    switch($action) {
    	case 'register':
    		register();
    		break;
    	case 'confirm':
    		confirm();
    		break;
    	case 'final':
    		final();
    		break;
    	default:
    		main();
    		break;
    }
    
    include('templates/footer.php');
    
    
    
    
    //=================================
    function final() {
    	global $db,$site_name,$admin_email;
    	$email = $_REQUEST['email'];
    	$code = $_REQUEST['code'];
    	$pass1 = $_REQUEST['pass1'];
    	$pass2 = $_REQUEST['pass2'];
    	
    	$db->query("select 1 from t_counter_tmp where id='$code' and email='$email'");
    	if($db->num_rows()) {
    		
    		if($pass1 == $pass2) {
    			$source = 'abcdefghijklmnopqrstuvwxyz0198765432';
    			list($usec, $sec) = explode(' ', microtime());
        			$seed = (float) $sec + ((float) $usec * 100000);
        			srand($seed);
    			
    			for($i=0;$i<20;$i++) {
    				$randval = rand(0,strlen($source)-1);
    				$secret .= $source[$randval];
    			}
    			
    			$db->query("insert into t_counter_profiles(id,email,pass,secret) values(null,'$email','$pass1','$secret')");
    			$db->query("select id from t_counter_profiles where email='$email' and pass = '$pass1'");
    			$db->next_record();
    			$id = $db->f('id');
    			$db->query("insert into t_counter_totals values($id,0)");
    			$db->query("delete from t_counter_tmp where email='$email'");
    			$content = 'Welcome to '.$site_name.'!<br><br><strong>Details:</strong><br>-------<br><br>id: '.$id.'<br>password: '.$pass1.'<br><br>Thanks,<br>Admin';
    			$content_screen = 'Welcome to '.$site_name.'!<br><br><strong>Details:</strong><br>-------<br><br>id: '.$id.'<br><br>Thanks,<br>Admin';
    			mail($email,'Welcome to '.$site_name,$content,"Content-Type: text/html\nFrom: $admin_email\n\n");
    			print 'You can now login into your member area. Click <a href="counter.php">here</a> to proceed.<br>';
    			print $content_screen;
    		} else {
    			print 'Passwords are different, <a href="#" onclick="history.back(-1)">go back to correct</a>.';
    		}
    		
    	} else {	
    		print "Not found!";
    	}
    }
    	
    	
    	
    function confirm() {
    	global $db;
    	$email = $_REQUEST['email'];
    	$code = $_REQUEST['code'];
    	$db->query("select 1 from t_counter_tmp where id='$code' and email='$email'");
    	if(!$db->num_rows()) {
    		print "Not found!";
    	} else {	
    		$ip = getIP();
    		$url = $_SERVER[PHP_SELF];
    		$tpl = new FastTemplate('templates');
    		$tpl->define(array(confirm  => 'confirm.php'));
    		$tpl->assign(array(IP => $ip, URL => $url, EMAIL => $email, CODE => $code));
    		$tpl->parse('FORM','confirm');
    		$tpl->FastPrint();
    	}
    }
    
    
    
    function main() {
    	$ip = getIP();
    	$url = $_SERVER[PHP_SELF];
    	$tpl = new FastTemplate('templates');
    	$tpl->define(array(register  => 'register.php'));
    	$tpl->assign(array(IP => $ip, URL => $url));
    	$tpl->parse('FORM','register');
    	$tpl->FastPrint();
    }
    
    
    function register() {
    	global $db,$admin_email,$site_name;
    	$email = $_REQUEST['email'];
    	$ip = getIP();
    		
    	$now = $code = time();
    	
    	// purge old temporary
    	$old = $now - 86400;
    	$db->query("delete from t_counter_tmp where date<'$old'");
    	// end of purge
    	
    	do {
    		$code--;
    		$db->query("select from t_counter_tmp where id='$code'");
    	} while($db->num_rows());
    	
    	$db->query("insert into t_counter_tmp values('$code','$email','$now')");
    	$link = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?action=confirm&email='.$email.'&code='.$code;
    	$url = '<a href="'.$link.'">'.$link.'</a>';
    	
    	$tpl = new FastTemplate('mailtemplates');
    	$tpl->define(array(register  => 'register.php'));
    	$tpl->assign(array(IP => $ip, URL => $url));
    	$tpl->parse('MAIL','register');
    	
    	mail($email,'Confirmation for signup at '.$site_name,$tpl->MAIL,"Content-Type: text/html\nFrom: $admin_email\n\n");
    	print 'Thank you, a confirmation email has been sent to: <strong>'.$email.'</strong><br>';
    }
    
    
    
    ?>
    PHP:
     
    yusiyuseff, Feb 6, 2009 IP
  2. steelaz

    steelaz Peon

    Messages:
    47
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    "final" is reserved keyword in PHP5, you should rename your function to something else.
     
    steelaz, Feb 6, 2009 IP
  3. InovvativeTech

    InovvativeTech Banned

    Messages:
    32
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3

    
    <?
    
    require('config.php');
    require('inc/main.inc.php');
    
    $action = $_REQUEST['action'];
    
    include('templates/header.php');
    
    switch($action) {
        case 'register':
            register();
            break;
        case 'confirm':
            confirm();
            break;
        case 'final':
            final1();
            break;
        default:
            main();
            break;
    }
    
    include('templates/footer.php');
    
    
    
    
    //=================================
    function final1() {
        global $db,$site_name,$admin_email;
        $email = $_REQUEST['email'];
        $code = $_REQUEST['code'];
        $pass1 = $_REQUEST['pass1'];
        $pass2 = $_REQUEST['pass2'];
       
        $db->query("select 1 from t_counter_tmp where id='$code' and email='$email'");
        if($db->num_rows()) {
           
            if($pass1 == $pass2) {
                $source = 'abcdefghijklmnopqrstuvwxyz0198765432';
                list($usec, $sec) = explode(' ', microtime());
                    $seed = (float) $sec + ((float) $usec * 100000);
                    srand($seed);
               
                for($i=0;$i<20;$i++) {
                    $randval = rand(0,strlen($source)-1);
                    $secret .= $source[$randval];
                }
               
                $db->query("insert into t_counter_profiles(id,email,pass,secret) values(null,'$email','$pass1','$secret')");
                $db->query("select id from t_counter_profiles where email='$email' and pass = '$pass1'");
                $db->next_record();
                $id = $db->f('id');
                $db->query("insert into t_counter_totals values($id,0)");
                $db->query("delete from t_counter_tmp where email='$email'");
                $content = 'Welcome to '.$site_name.'!<br><br><strong>Details:</strong><br>-------<br><br>id: '.$id.'<br>password: '.$pass1.'<br><br>Thanks,<br>Admin';
                $content_screen = 'Welcome to '.$site_name.'!<br><br><strong>Details:</strong><br>-------<br><br>id: '.$id.'<br><br>Thanks,<br>Admin';
                mail($email,'Welcome to '.$site_name,$content,"Content-Type: text/html\nFrom: $admin_email\n\n");
                print 'You can now login into your member area. Click <a href="counter.php">here</a> to proceed.<br>';
                print $content_screen;
            } else {
                print 'Passwords are different, <a href="#" onclick="history.back(-1)">go back to correct</a>.';
            }
           
        } else {   
            print "Not found!";
        }
    }
       
       
       
    function confirm() {
        global $db;
        $email = $_REQUEST['email'];
        $code = $_REQUEST['code'];
        $db->query("select 1 from t_counter_tmp where id='$code' and email='$email'");
        if(!$db->num_rows()) {
            print "Not found!";
        } else {   
            $ip = getIP();
            $url = $_SERVER[PHP_SELF];
            $tpl = new FastTemplate('templates');
            $tpl->define(array(confirm  => 'confirm.php'));
            $tpl->assign(array(IP => $ip, URL => $url, EMAIL => $email, CODE => $code));
            $tpl->parse('FORM','confirm');
            $tpl->FastPrint();
        }
    }
    
    
    
    function main() {
        $ip = getIP();
        $url = $_SERVER[PHP_SELF];
        $tpl = new FastTemplate('templates');
        $tpl->define(array(register  => 'register.php'));
        $tpl->assign(array(IP => $ip, URL => $url));
        $tpl->parse('FORM','register');
        $tpl->FastPrint();
    }
    
    
    function register() {
        global $db,$admin_email,$site_name;
        $email = $_REQUEST['email'];
        $ip = getIP();
           
        $now = $code = time();
       
        // purge old temporary
        $old = $now - 86400;
        $db->query("delete from t_counter_tmp where date<'$old'");
        // end of purge
       
        do {
            $code--;
            $db->query("select from t_counter_tmp where id='$code'");
        } while($db->num_rows());
       
        $db->query("insert into t_counter_tmp values('$code','$email','$now')");
        $link = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?action=confirm&email='.$email.'&code='.$code;
        $url = '<a href="'.$link.'">'.$link.'</a>';
       
        $tpl = new FastTemplate('mailtemplates');
        $tpl->define(array(register  => 'register.php'));
        $tpl->assign(array(IP => $ip, URL => $url));
        $tpl->parse('MAIL','register');
       
        mail($email,'Confirmation for signup at '.$site_name,$tpl->MAIL,"Content-Type: text/html\nFrom: $admin_email\n\n");
        print 'Thank you, a confirmation email has been sent to: <strong>'.$email.'</strong><br>';
    }
    
    
    
    ?>
    
    PHP:
     
    InovvativeTech, Feb 7, 2009 IP