Jump to content

Error when sending email with a $_SESSION as destinatary


Recommended Posts

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/ibn/public_html/emailbomber/actions/sendemails.php on line 8

 

<?php

session_start();	

require_once('../includes/link.php');



$errmsg_arr = array();

$errflag = false;



mail("$_SESSION['SESS_EMAIL']", "Teste - Enviar Emails", "Olá, ".$_SESSION['SESS_NAME']."\n\nTeste - Enviar Emails, "From Teste");

$errmsg_arr[] = 'Os email serao enviados dentro de no maximo 48 horas.';

$errflag = true;

$_SESSION['ERRMSG_ARR'] = $errmsg_arr;

session_write_close();

header("location: ../users/user/sendemails.php");



?>

Link to comment
Share on other sites

Remove Extra "

mail("$_SESSION['SESS_EMAIL']", "Teste - Enviar Emails", "Olá, ".$_SESSION['SESS_NAME']."\n\nTeste - Enviar Emails, "From Teste");

 

after removing

mail("$_SESSION['SESS_EMAIL']", "Teste - Enviar Emails", "Olá, ".$_SESSION['SESS_NAME']."\n\nTeste - Enviar Emails,From Teste");

Link to comment
Share on other sites

The error persist

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/ibn/public_html/emailbomber/actions/sendemails.php on line 8

 

<?php

session_start();	

require_once('../includes/link.php');



$errmsg_arr = array();

$errflag = false;



mail("$_SESSION['SESS_EMAIL']", "Teste - Enviar Emails", "Olá, ".$_SESSION['SESS_NAME']."\n\nTeste - Enviar Emails, From Teste");

$errmsg_arr[] = 'Os email serao enviados dentro de no maximo 48 horas.';

$errflag = true;

$_SESSION['ERRMSG_ARR'] = $errmsg_arr;

session_write_close();

header("location: ../users/user/sendemails.php");



?>

Link to comment
Share on other sites

Using just this

 

<?php

session_start();	

require_once('../includes/link.php');



$errmsg_arr = array();

$errflag = false;

echo "$_SESSION['SESS_EMAIL]";



?>

 

I got the same error

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/ibn/public_html/emailbomber/actions/sendemails.php on line 8

Link to comment
Share on other sites

Look at the syntax highlighting in your post, this should fix it.

 

echo "{$_SESSION['SESS_EMAIL']}";

 

If you are using associative indexed arrays inside of doube quotes, you need to bracket them for it to parse correctly. While we are on this topic, you do not need to surround the variable in quotes if it is not apart of anything but itself. So I would just do this, unless there is more than just that one echo statement:

 

echo $_SESSION['SESS_EMAIL'];

Link to comment
Share on other sites

I made some changes on the script.

 

<?php

require_once('../includes/link.php');

$query = "SELECT * FROM emails";
$result = mysql_query($query);

while($row = mysql_fetch_array($result)) {
	mail("$row['email']", "Teste - Enviar Emails", "Teste - Enviar Emails", "From: Teste - Enviar Emails");
	sleep(3);
}



?>

 

But is giving Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING on

 

mail("$row['email']", "Teste - Enviar Emails", "Teste - Enviar Emails", "From: Teste - Enviar Emails");

Link to comment
Share on other sites

Why do I even bother replying if you are not going to read my post about associative indexed arrays and how to handle them?

 

mail($row['email'], "Teste - Enviar Emails", "Teste - Enviar Emails", "From: Teste - Enviar Emails");

 

OR

 

mail("{$row['email']}", "Teste - Enviar Emails", "Teste - Enviar Emails", "From: Teste - Enviar Emails");

 

For an explanation of WHY see my above post where I outlined how to fix your issue. And just incase you are too bold headed that you cannot scroll up, here is a link: http://www.phpfreaks.com/forums/index.php?topic=343361.msg1619881#msg1619881

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.