Jump to content

[SOLVED] unexpected T_ENCAPSED_AND_WHITESPACE - expecting T_STRING or T_VARIABLE or T_NUM


sam06

Recommended Posts

Any ideas guys?

My code:

<?php
mysql_connect***********************

$query = "SELECT * FROM usertable"; 
$result = mysql_query($query) or die(mysql_error());
$name = "Free Sweet Rewards";
$email = "[email protected]";

while($row = mysql_fetch_array( $result )) {
$message = "Hi there $row['username'],\nFree Sweet Rewards has recently added a load of new offers avaliable.\nThere are also a great deal of daily clicks avaliable for you to do. These clicks can mean you can order a package in just a week!\nPlease let us know what you think of the new offers!\nKind Regards,\nSam Hale - Chief Executive Officer, Ramico Media.";
$to = "[email protected]";
$subject = "Message from $name";
$body = "$message";
$headers = "From: $email\r\n" .
    "X-Mailer: php";
} 
?>

 

It's not looping yet, I just wanted to test it with my email address before sending it to the database.

 

It's coming up with error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in email1.php on line 11

 

I've tried it with spaces after the \n, and without. No idea.

 

Many Thanks,

Sam

If you use array values in "" strings, you have to put them in curly brackets {}

 

$message = "Hi there {$row['username']},\nFree Sweet...";

 

Good to know for the future. Before, I just used to close and reopen the quotation. Ie/

$message = "Hi there ".$row['username'].",\nFree Sweet...";

Archived

This topic is now archived and is closed to further replies.

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