shwetapandit Posted July 22, 2013 Share Posted July 22, 2013 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 <[email protected]>"; //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 https://forums.phpfreaks.com/topic/280392-syntax-error-unexpected-t_encapsed_and_whitespace-expecting-t_string-or-t_variable-or-t_num_string-error/ Share on other sites More sharing options...
Muddy_Funster Posted July 22, 2013 Share Posted July 22, 2013 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 https://forums.phpfreaks.com/topic/280392-syntax-error-unexpected-t_encapsed_and_whitespace-expecting-t_string-or-t_variable-or-t_num_string-error/#findComment-1441656 Share on other sites More sharing options...
shwetapandit Posted July 23, 2013 Author Share Posted July 23, 2013 thanks for reply. but i follow all the rules of heredoc carefully.then why there is bug.how it can be fix.i can't find Link to comment https://forums.phpfreaks.com/topic/280392-syntax-error-unexpected-t_encapsed_and_whitespace-expecting-t_string-or-t_variable-or-t_num_string-error/#findComment-1441762 Share on other sites More sharing options...
Muddy_Funster Posted July 23, 2013 Share Posted July 23, 2013 I coppied and ran the code above, I got the same massage about T_ENCAPSED_AND_WHITE SPACE - I then removed the white space at the start of the line "END_OF_BLOCK;" and it ran through fine. hint: if someone gives you a suggestion - try following it up. Link to comment https://forums.phpfreaks.com/topic/280392-syntax-error-unexpected-t_encapsed_and_whitespace-expecting-t_string-or-t_variable-or-t_num_string-error/#findComment-1441763 Share on other sites More sharing options...
shwetapandit Posted July 23, 2013 Author Share Posted July 23, 2013 thanks a ton..... i realize the fact.i already spent two days for this..now get solves by ur suggestion .thanks again Link to comment https://forums.phpfreaks.com/topic/280392-syntax-error-unexpected-t_encapsed_and_whitespace-expecting-t_string-or-t_variable-or-t_num_string-error/#findComment-1441765 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.