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 = "samuelhale@btinternet.com";

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 = "samuelhale@btinternet.com";
$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

Link to comment
Share on other sites

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...";

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.