Jump to content

Syntax Error in function


mbrown
 Share

Recommended Posts

I am getting an error in my following code. The error is 

 

 

PHP Parse error:  syntax error, unexpected '.=' (T_CONCAT_EQUAL), expecting ',' or ';' in /var/www/html/board/mail.php on line 25

 

This would make it on the this line:

 global $body .= "<h1>" . $motionname . "</h1>

<?php
	function mailing($motionid)
	{
		$motionArray = array($motionid);
		foreach ($motionArray as $motion)
		{
			//Database Connection
			include_once ('include/db-config.php');
			$motion=$db_con->prepare ("SELECT * from motions where motion_id = :motionid");
                        $motion->bindParam(':motionid',$motionid);
                        $motion->execute();
			$body="<html>
					<head>
						<title>Status of Motion</title>
					</head>
					<body>";
                        while ($row=$motion->fetch(PDO::FETCH_ASSOC))
                        {
                                $motionid=$row['motion_id'];
                                $motionname=$row['motion_name'];
                                $dateadded=$row['dateadded'];
                                $motiondesc=$row['motion_description'];
                                $disposition=$row['motion_disposition'];

                                global $body .= "<h1>" . $motionname . "</h1>
                                	<h2>Date Added:</h2>" . $dateadded . "<br />
                                	<h2>Motion Text</h2>" .
                                	$motiondesc;
                                	"<h2>Disposition:</h2>" .
                                	$disposition;
			}//End of while

			global $body .= "<br /><br />
					<h2>Current Votes</h2>
					<table border=\"1\" width=\"100%\">
					<tr>
						<th>User</th>
						<th>Date</th>
						<th>Vote</th>
					</tr>";

			$votes=$db_con->prepare(
                        	"SELECT u.first_name, u.last_name, v.time, v.vote from votes v 
				inner join motions m on m.motion_id=v.motions_id INNER join users u on 
				u.users_id=v.users_id where m.motion_id=:motionid ORDER BY v.time ASC;");
                     	
			$votes->bindParam(':motionid',$motionid);
                        $votes->execute();
                        while ($row=$votes->fetch(PDO::FETCH_ASSOC))
                        {
                        	$firstname=$row['first_name'];
                                $lastname=$row['last_name'];
                                $votetime=$row['time'];
                                $votecast=$row['vote'];
                                global $body .= "<tr>
					<td>" . $firstname . " " . $lastname . "</td>
                                        <td>" . $votetime . "</td>
                                        <td>" . $votecast . "</td>
                                        </tr>";
                        }// while ($row=$votes->fetch(PDO::FETCH_ASSOC))
    			global $body .= "</table>";
			global $body .= "<br /><br />
					<h2>Discussions</h2>
					<table border=\"1\" width=\"1\">
					<tr>
						<th>User</th>
						<th>Date</th>
						<th>Comment</th>
					</tr>";

			$motiondiscussions=$db_con->prepare(
				"SELECT u.first_name,u.last_name,d.dateadded,d.discussion_text
				 from users u inner join discussion d on d.user_id=u.users_id where d.motion_id=:motionid");
			$motiondiscussions->bindParam(':motionid',$motionid);
                       	$motiondiscussions->execute();
			while ($row=$motiondiscussions->fetch(PDO::FETCH_ASSOC))
			{
				$firstname=$row['first_name'];
				$lastname=$row['last_name'];
                                $discussiontime=$row['dateadded'];
                                $discussiontext=$row['discussion_text'];
				global $body .= "<tr>
							<td>" . $firstname . " " . $lastname . "</td>
							<td>" . $discussiontime . "</td>
							<td>" . $discussiontext . "</td>
						</tr>";
			}//end of while
			global $body .= "</table>";

			global $body .= "</body>
				</html>";
		}//end of foreach

		$email="michaelbrown.tsbod@gmail.com";
		$to="michaelbrown.tsbod@gmail.com";
		$subject = "Summary for Motion " . $motionid;
		$message = $body;
		$headers[] = 'MIME-Version: 1.0';
		$headers[] = 'Content-type: text/html; charset=iso-8859-1';
		$headers[] = 'To: Michael Brown <michaelbrown.tsbod@gmail.com>';
		$headers[]= 'From: Tanyard Springs Votes <noreply@tanyardspringshoa.com>';
		
		//mailing
		mail($to,$subject,$message, implode("\r\n", $headers));
	}//end of function
?>
Link to comment
Share on other sites

The code makes no sense. You cannot combine a global declaration of a variable with other operations. The $body variable obviously isn't even global; it's a local variable of the function.

 

So I suggest two things: Learn what global means (or avoid it altogether). And get an IDE, as we already discussed.

Link to comment
Share on other sites

Additionally, you will want to be careful with concatenation that spans over multiple lines of code. Note that the following block has an extra semi-colon:

$body .= "<h1>" . $motionname . "</h1>
<h2>Date Added:</h2>" . $dateadded . "<br />
<h2>Motion Text</h2>" .
$motiondesc;
"<h2>Disposition:</h2>" .
$disposition;
Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

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