Jump to content

syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING error


shwetapandit
Go to solution Solved by Muddy_Funster,

Recommended Posts

i tried a lot bt can't get rid by parse error syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\sendmymail.php on line 19 in this prog if anyone suggest sol then it will be a great help for me.thanks in advance.my script is here:

 

 

 

<?php
 include 'subscriber_include.php';
 if (!$_POST) {
 //haven’t seen the form, so display it
 $display_block = <<<END_OF_BLOCK
 <form method="POST" action="$_SERVER[php_SELF]">

 <p><label for="subject">Subject:</label><br/>
 <input type="text" id="subject" name="subject" size="40" /></p>

 <p><label for="message">Mail Body:</label><br/>
 <textarea id="message" name="message" cols="50"
  rows="10"></textarea></p>
 <button type="submit" name="submit" value="submit">Submit</button>
 </form>
 END_OF_BLOCK;
 } else if ($_POST) {
 //want to send form, so check for required fields
 if (($_POST['subject'] == "") || ($_POST['message'] == "")) {
 header("Location:sendmymail.php");
 exit();
 }

 //connect to database
 doDB();

 if (mysqli_connect_errno()) {
 //if connection fails, stop script execution
 printf("Connect failed: %s\n", mysqli_connect_error());
 exit();
 } else {
 //otherwise, get emails from subscribers list
 $sql = "SELECT email FROM Subscribers_db";
 $result = mysqli_query($mysqli, $sql)
 or die(mysqli_error($mysqli));

 //create a From: mailheader
 $mailheaders = "From: Your Mailing List
 <shweta.pandit2012@gmail.com>";
 //loop through results and send mail
 while ($row = mysqli_fetch_array($result)) {
 set_time_limit(0);
 $email = $row['email'];
 mail("$email", stripslashes($_POST['subject']),
 stripslashes($_POST['message']), $mailheaders);
 $display_block .= "newsletter sent to: ".$email."<br/>";
 }
 mysqli_free_result($result);
 mysqli_close($mysqli);
 }
 }
 ?>
 <!DOCTYPE html>
 <html>
 <head>
 <title>Sending a Newsletter</title>
 </head>
 <body>
 <h1>Send a Newsletter</h1>
 <?php echo $display_block; ?>
 </body>
 </html>

Link to comment
Share on other sites

commonly this comes from malformed heredoc statements - you can have NO whitespace on the line of the opening heredoc decleration after the name of the heredoc and you can have NO whitespace on the closing line of the heredoc before the heredoc name. Make absoloutly certain that there are no tabs or spaces on these lines that shouldn't be.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

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