mbrown Posted March 8, 2017 Share Posted March 8, 2017 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 ?> Quote Link to comment https://forums.phpfreaks.com/topic/303391-syntax-error-in-function/ Share on other sites More sharing options...
Jacques1 Posted March 8, 2017 Share Posted March 8, 2017 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. Quote Link to comment https://forums.phpfreaks.com/topic/303391-syntax-error-in-function/#findComment-1543904 Share on other sites More sharing options...
mbrown Posted March 8, 2017 Author Share Posted March 8, 2017 I was corrected on the global. That has been removed. What is going on with this code is that it is a mailing function. Quote Link to comment https://forums.phpfreaks.com/topic/303391-syntax-error-in-function/#findComment-1543920 Share on other sites More sharing options...
cyberRobot Posted March 8, 2017 Share Posted March 8, 2017 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; Quote Link to comment https://forums.phpfreaks.com/topic/303391-syntax-error-in-function/#findComment-1543922 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.