SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    934
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Arrow Any humble help for this error.

    hi guys

    this is the error,
    Code:
    Parse error: syntax error, unexpected T_FUNCTION in /home/joealex3/public_html/save_winners.php on line 142
    this is the codes below,
    Code:
    <?php
    include 'opendb.php';
    //get all unique subscribers first.
    	$query = "SELECT * FROM users ORDER BY user_name ASC";
    	$result=mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error());
    	
    	$i=0;
    	while($row = mysql_fetch_array($result)) {
    		$unique_names[$i] = $row['user_name'];		
    		$i++;
    	}
    
    //fill invited_by
    	$i=0;
    	$c=count($unique_names);
    	while($i<=$c) {
    		//find referer_name in invited table
    		$query = "SELECT * FROM invited WHERE invited='$unique_names[$i]' AND date_check='0000-00-00 00:00:00'";	
    		$result=mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error());
    
    		$row = mysql_fetch_array($result);
    		$referer_name = $row['referer_name'];
    		
    		$query = "UPDATE users SET invited_by='$referer_name' WHERE user_name='$unique_names[$i]'";
    		mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error());
    		
    		$i++;
    	}
    
    //Get ranking
    //get subscribers with invited_by not blank and date equal to 00-00-00-00
    	$query = "SELECT * FROM users WHERE invited_by!='' AND date_check='0000-00-00 00:00:00'";	
    	$result=mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error());
    	
    	$i=0;
    	while($row = mysql_fetch_array($result)) {
    		$invited[$i] = $row['user_name'];		
    		$referer[$i] = $row['invited_by'];		
    		#echo "<b>{$invited[$i]} </b>". $referer[$i];
    		#echo "<br>";
    		
    		$i++;
    	}
    
    	if (!empty($referer)) {	
    		$unique_referer = array_unique($referer);
    
    		$query = "SELECT invited_by, COUNT(*) AS total FROM users WHERE invited_by!='' AND date_check='0000-00-00 00:00:00' GROUP BY invited_by ORDER BY total DESC LIMIT 1";	
    		$result=mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error());
    
    		$i=1;
    		while($row = mysql_fetch_array($result)) {
    			$invited_by = $row['invited_by'];		
    			$total = $row['total'];		
    			#echo "{$i} <b>{$invited_by}  {$total}</b>";
    			#echo "<br>";
    			
    		$i++;
    		}
    
    		//get all new subscriber.
    		//get the highest winning ranking number.
    		//use that number to get ties.
    		//store into database		
    		//email administrator
    		//email member winners
    		$query = "SELECT invited_by, COUNT(*) AS total FROM users WHERE invited_by!='' AND date_check='0000-00-00 00:00:00' GROUP BY invited_by HAVING total=$total ORDER BY total DESC LIMIT 1";
    		$result=mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error());
    
    		$i=1;
    		while($row = mysql_fetch_array($result)) {
    			$invited_by = $row['invited_by'];		
    			$total = $row['total'];		
    			#echo "{$i} <b>{$invited_by}  {$total}</b>";
    			#echo "<br>";
    			
    		$i++;
    		}
    
    		$query = "SELECT invited_by, COUNT(*) AS total FROM users WHERE invited_by!='' AND date_check='0000-00-00 00:00:00' GROUP BY invited_by HAVING total=$total ORDER BY total DESC";
    		$result=mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error());
    
    		$i=0;
    		while($row = mysql_fetch_array($result)) {
    			$invited_by2[$i] = $row['invited_by'];		
    			$total2[$i] = $row['total'];		
    			echo "{$i} <b>{$invited_by2[$i]}  {$total2[$i]}</b>";
    			echo "<br>";
    			
    		$i++;
    		}
    		
    		echo "<br>";
    		echo "<br>";	
    		
    		//get information of the winners.
    		$i=1;
    		$j=0;
    		$c=count($invited_by2);
    		while($i <= $c) {
    			$query = "SELECT * FROM users WHERE user_name='$invited_by2[$j]' ORDER BY user_name ASC";
    			$result=mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error());
    			$row = mysql_fetch_array($result);
    
    			$winners_user_name[$j] = $row['user_name'];
    			$winners_email[$j] = $row['email'];
    			$winners_email_alternate[$j] = $row['email_alternate'];
    			$winners_date_won[$j] = date("F j, Y, g:i a");
    
    			echo "{$i} . {$winners_user_name[$j]} {$winners_email[$j]} {$winners_email_alternate[$j]} {$winners_date_won[$j]}";
    			echo "<br>";
    			$i++;
    			$j++;
    		}
    		
    		
    		$i=1;
    		$j=0;
    		$c=count($winners_user_name);
    		while($i <= $c) {
    			//save winners information into database		
    			/*
    			$query = "INSERT INTO dawinners (user_name, email, email_alternate, date_won) 
    			VALUES ('$winners_user_name[$j]', '$winners_email[$j]', '$winners_email_alternate[$j]', now())"; 
    			mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error());
    			*/
    
    		
    			//email winners
    			email_winners($winners_user_name, $winners_email);
    		
    			$i++;
    			$j++;
    		}
    	
    	}
    ?>
    
    
    <?hp
    
    	function email_winners($winners_user_name, $winners_email) {
    			$i=0;
    			foreach($winners_user_name as $value) {
    			
    				$to = $winners_email[$i];
    				$subject = "You won the Lexingtonssundenvalues.com Contest.";
    				
    				$message = "
    				<html>
    <head>
    <meta http-equiv='Content-Type' content='text/html; charset=windows-1252'>
    <title></title>
    </head>
    
    <body>
    
    <table border='0' width='500' id='table1' cellspacing='0' cellpadding='0'>
    	<tr>
    		<td background='http://lexingtonssuddenvalues.com/images_contest/winning_card.jpg'>
    &nbsp;<br><br><br><br><br><br><br><br><br>
    			<p>&nbsp;<p>&nbsp;<p><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Congratulation test $winners_user_name[$i]!</b><br>
    			<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    			Testing from Lexingtonssundenvalues.com Contest!<br>
    			<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    			For information regarding your ---- please inquire <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    			at Lexingtonssundenvalues.com<br>
    			<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    			<b>Thank you.</b> 
    <p>&nbsp;<p>&nbsp;<p>&nbsp;<p>&nbsp;<p>&nbsp;<p>&nbsp;
    		<p>&nbsp;</p><br><br><br><br><br><br><br>
    		<p>&nbsp;</p><br><br><br><br></td>
    	</tr>
    </table>
    
    </body>
    
    </html>
    ";
    				
    				// To send HTML mail, the Content-type header must be set
    				$headers  = 'MIME-Version: 1.0' . "\r\n";
    				$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    
    				// Additional headers
    				#$headers .= 'To: Winner <'.$winners_email.'>' . "\r\n";
    				$headers .= 'From: Lexingtonssundevalues Contest <donotreply@lexingtonssudenvalues.com>' . "\r\n";
    
    				// Mail it
    				mail($to, $subject, $message, $headers);
    				
    				$i++;
    			}
    	}
    
    #Parse error: syntax error, unexpected T_FUNCTION in /home/joealex3/public_html/save_winners.php on line 137
    #fix select
    
    include 'closedb.php';
    ?>
    I hope you can help me,

    Thank you very much in advance.

  2. #2
    Use The Cloud
    Join Date
    Jan 2006
    Location
    Boise, ID
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your problem is very simple. The error says there is a problem at line 142.

    So you need to go to line 142 and look at the immediately surrounding lines.

    Check that line of code and the solution should be pretty obvious.
    Brad Hanson, Web Applications & Scalability Specialist
    ► Is your website outgrowing its current hosting solution?
    ► PM me for a FREE scalability consult!
    ► USA Based: Available by Phone, Skype, AIM, and E-mail.

  3. #3
    SitePoint Zealot
    Join Date
    May 2006
    Location
    Jhyalipati,Chapagaun-9, Lalitpur, Bagmati, Nepal
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Modified code
    PHP Code:
    <?php
    include 'opendb.php';
    //get all unique subscribers first.
        
    $query "SELECT * FROM users ORDER BY user_name ASC";
        
    $result=mysql_query($query) or die("Problem with the query: $query on line " __LINE__ '<br>' mysql_error());
        
        
    $i=0;
        while(
    $row mysql_fetch_array($result)) {
            
    $unique_names[$i] = $row['user_name'];        
            
    $i++;
        }

    //fill invited_by
        
    $i=0;
        
    $c=count($unique_names);
        while(
    $i<=$c) {
            
    //find referer_name in invited table
            
    $query "SELECT * FROM invited WHERE invited='$unique_names[$i]' AND date_check='0000-00-00 00:00:00'";    
            
    $result=mysql_query($query) or die("Problem with the query: $query on line " __LINE__ '<br>' mysql_error());

            
    $row mysql_fetch_array($result);
            
    $referer_name $row['referer_name'];
            
            
    $query "UPDATE users SET invited_by='$referer_name' WHERE user_name='$unique_names[$i]'";
            
    mysql_query($query) or die("Problem with the query: $query on line " __LINE__ '<br>' mysql_error());
            
            
    $i++;
        }

    //Get ranking
    //get subscribers with invited_by not blank and date equal to 00-00-00-00
        
    $query "SELECT * FROM users WHERE invited_by!='' AND date_check='0000-00-00 00:00:00'";    
        
    $result=mysql_query($query) or die("Problem with the query: $query on line " __LINE__ '<br>' mysql_error());
        
        
    $i=0;
        while(
    $row mysql_fetch_array($result)) {
            
    $invited[$i] = $row['user_name'];        
            
    $referer[$i] = $row['invited_by'];        
            
    #echo "<b>{$invited[$i]} </b>". $referer[$i];
            #echo "<br>";
            
            
    $i++;
        }

        if (!empty(
    $referer)) {    
            
    $unique_referer array_unique($referer);

            
    $query "SELECT invited_by, COUNT(*) AS total FROM users WHERE invited_by!='' AND date_check='0000-00-00 00:00:00' GROUP BY invited_by ORDER BY total DESC LIMIT 1";    
            
    $result=mysql_query($query) or die("Problem with the query: $query on line " __LINE__ '<br>' mysql_error());

            
    $i=1;
            while(
    $row mysql_fetch_array($result)) {
                
    $invited_by $row['invited_by'];        
                
    $total $row['total'];        
                
    #echo "{$i} <b>{$invited_by}  {$total}</b>";
                #echo "<br>";
                
            
    $i++;
            }

            
    //get all new subscriber.
            //get the highest winning ranking number.
            //use that number to get ties.
            //store into database        
            //email administrator
            //email member winners
            
    $query "SELECT invited_by, COUNT(*) AS total FROM users WHERE invited_by!='' AND date_check='0000-00-00 00:00:00' GROUP BY invited_by HAVING total=$total ORDER BY total DESC LIMIT 1";
            
    $result=mysql_query($query) or die("Problem with the query: $query on line " __LINE__ '<br>' mysql_error());

            
    $i=1;
            while(
    $row mysql_fetch_array($result)) {
                
    $invited_by $row['invited_by'];        
                
    $total $row['total'];        
                
    #echo "{$i} <b>{$invited_by}  {$total}</b>";
                #echo "<br>";
                
            
    $i++;
            }

            
    $query "SELECT invited_by, COUNT(*) AS total FROM users WHERE invited_by!='' AND date_check='0000-00-00 00:00:00' GROUP BY invited_by HAVING total=$total ORDER BY total DESC";
            
    $result=mysql_query($query) or die("Problem with the query: $query on line " __LINE__ '<br>' mysql_error());

            
    $i=0;
            while(
    $row mysql_fetch_array($result)) {
                
    $invited_by2[$i] = $row['invited_by'];        
                
    $total2[$i] = $row['total'];        
                echo 
    "{$i} <b>{$invited_by2[$i]}  {$total2[$i]}</b>";
                echo 
    "<br>";
                
            
    $i++;
            }
            
            echo 
    "<br>";
            echo 
    "<br>";    
            
            
    //get information of the winners.
            
    $i=1;
            
    $j=0;
            
    $c=count($invited_by2);
            while(
    $i <= $c) {
                
    $query "SELECT * FROM users WHERE user_name='$invited_by2[$j]' ORDER BY user_name ASC";
                
    $result=mysql_query($query) or die("Problem with the query: $query on line " __LINE__ '<br>' mysql_error());
                
    $row mysql_fetch_array($result);

                
    $winners_user_name[$j] = $row['user_name'];
                
    $winners_email[$j] = $row['email'];
                
    $winners_email_alternate[$j] = $row['email_alternate'];
                
    $winners_date_won[$j] = date("F j, Y, g:i a");

                echo 
    "{$i} . {$winners_user_name[$j]} {$winners_email[$j]} {$winners_email_alternate[$j]} {$winners_date_won[$j]}";
                echo 
    "<br>";
                
    $i++;
                
    $j++;
            }
            
            
            
    $i=1;
            
    $j=0;
            
    $c=count($winners_user_name);
            while(
    $i <= $c) {
                
    //save winners information into database        
                /*
                $query = "INSERT INTO dawinners (user_name, email, email_alternate, date_won) 
                VALUES ('$winners_user_name[$j]', '$winners_email[$j]', '$winners_email_alternate[$j]', now())"; 
                mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error());
                */

            
                //email winners
                
    email_winners($winners_user_name$winners_email);
            
                
    $i++;
                
    $j++;
            }
        
        }
    ?>


    <?php

        
    function email_winners($winners_user_name$winners_email) {
                
    $i=0;
                foreach(
    $winners_user_name as $value) {
                
                    
    $to $winners_email[$i];
                    
    $subject "You won the Lexingtonssundenvalues.com Contest.";
                    
                    
    $message "
                    <html>
    <head>
    <meta http-equiv='Content-Type' content='text/html; charset=windows-1252'>
    <title></title>
    </head>

    <body>

    <table border='0' width='500' id='table1' cellspacing='0' cellpadding='0'>
        <tr>
            <td background='http://lexingtonssuddenvalues.com/images_contest/winning_card.jpg'>
    &nbsp;<br><br><br><br><br><br><br><br><br>
                <p>&nbsp;<p>&nbsp;<p><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Congratulation test 
    $winners_user_name[$i]!</b><br>
                <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                Testing from Lexingtonssundenvalues.com Contest!<br>
                <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                For information regarding your ---- please inquire <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                at Lexingtonssundenvalues.com<br>
                <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <b>Thank you.</b> 
    <p>&nbsp;<p>&nbsp;<p>&nbsp;<p>&nbsp;<p>&nbsp;<p>&nbsp;
            <p>&nbsp;</p><br><br><br><br><br><br><br>
            <p>&nbsp;</p><br><br><br><br></td>
        </tr>
    </table>

    </body>

    </html>
    "
    ;
                    
                    
    // To send HTML mail, the Content-type header must be set
                    
    $headers  'MIME-Version: 1.0' "\r\n";
                    
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";

                    
    // Additional headers
                    #$headers .= 'To: Winner <'.$winners_email.'>' . "\r\n";
                    
    $headers .= 'From: Lexingtonssundevalues Contest <donotreply@lexingtonssudenvalues.com>' "\r\n";

                    
    // Mail it
                    
    mail($to$subject$message$headers);
                    
                    
    $i++;
                }
        }

    #Parse error: syntax error, unexpected T_FUNCTION in /home/joealex3/public_html/save_winners.php on line 137
    #fix select

    include 'closedb.php';
    ?>
    Simply Sajan


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •