954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Mail Function syntax error

I am trying to put a variable in as the value of the mail function on my script. I am relatively new to php and I may be making a simple mistake. Here is the script:

$busmail = $_POST['field_2']

mail(" . $busmail . ","Order Confirmation","Your Order Has Been Received And Is Now Being Processed.

 
Quantity: " . $_POST['field_3'] . " 
Size: " . $_POST['field_4'] . " 
Special Instructions: " . $_POST['field_5'] . " 

Please contact us with any questions or concerns at <A href="mailto:c2c@capturedtocanvas.com" target=_top>c2c@capturedtocanvas.com</A> 
");


and here is the error I am getting:

PHP Parse error: syntax error, unexpected T_STRING in /hermes/bosweb/web171/b1716/sl.c2cadmin/C2C/Form/processor.php on line 44

Thanks in advance.

jjasoningram
Newbie Poster
12 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
 

Here is the entire script so you can see which line is 44.

<?php

$where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

// File upload handling
if($_FILES['field_6']['name']!=''){
$field_6_filename = "file_6_".date("sihdmY").substr($_FILES['field_6']['name'],strlen($_FILES['field_6']['name'])-4);
if(!move_uploaded_file($_FILES['field_6']['tmp_name'], "./files/".$field_6_filename)){
die("File " .  $_FILES['field_6']['name'] . " was not uploaded.");
}
}

include("config.inc.php");
$link = mysql_connect($db_host,$db_user,$db_pass);
if(!$link) die ('Could not connect to database: '.mysql_error());
mysql_select_db($db_name,$link);
$query = "INSERT into `".$db_table."` (field_1,field_2,field_3,field_4,field_5,field_6,field_7,field_8,field_9,field_10,field_11,field_12,field_13,field_14) VALUES ('" . $_POST['field_1'] . "','" . $_POST['field_2'] . "','" . $_POST['field_3'] . "','" . $_POST['field_4'] . "','" . $_POST['field_5'] . "','" . $_POST['field_6'] . "','" . $_POST['field_7'] . "','" . $_POST['field_8'] . "','" . $_POST['field_9'] . "','" . $_POST['field_10'] . "','" . $_POST['field_11'] . "','" . $_POST['field_12'] . "','" . $_POST['field_13'] . "','" . $_POST['field_14'] . "')";
mysql_query($query);
mysql_close($link);

mail("","phpFormGenerator - Form submission","Form data:

Customer Name: " . $_POST['field_1'] . " 
Customer Email: " . $_POST['field_2'] . " 
Quantity: " . $_POST['field_3'] . " 
Size: " . $_POST['field_4'] . " 
Special Instructions: " . $_POST['field_5'] . " 
Upload Your Image Here: ".$where_form_is."files/".$field_6_filename." (original file name: " . $_FILES['field_6']['name'] . ")
Shipping Information: " . $_POST['field_7'] . " 
Ship to Address: " . $_POST['field_8'] . " 
Please read and check this option or your image will not be reproduced.: " . $_POST['field_9'] . " 
Alterations: " . $_POST['field_10'] . " 
: " . $_POST['field_11'] . " 
: " . $_POST['field_12'] . " 
: " . $_POST['field_13'] . " 
: " . $_POST['field_14'] . " 



");

$busmail = $_POST['field_2']

mail(" . $busmail . ","Order Confirmation","Your Order Has Been Received And Is Now Being Processed.

 
Quantity: " . $_POST['field_3'] . " 
Size: " . $_POST['field_4'] . " 
Special Instructions: " . $_POST['field_5'] . " 

Please contact us with any questions or concerns at <A href="mailto:c2c@capturedtocanvas.com" target=_top>c2c@capturedtocanvas.com</A> 
");

include("confirm.html");

?>
jjasoningram
Newbie Poster
12 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
 
mail(" . $busmail . ","Order Confirmation","Your Order Has Been Received And Is Now Being Processed.


needs to be

mail($busmail, "Order Confirmation","Your Order Has Been Received And Is Now Being Processed.
Auzzie
Junior Poster
122 posts since Nov 2007
Reputation Points: 16
Solved Threads: 16
 

yeah,no need for the quotes because it is only a variable.

ryan_vietnow
Posting Pro
578 posts since Aug 2007
Reputation Points: 28
Solved Threads: 71
 

Plus the quotes wernt closed off to allow for the string concantation

Auzzie
Junior Poster
122 posts since Nov 2007
Reputation Points: 16
Solved Threads: 16
 

Ok, took out the quotes and still getting an error code. The error will follow after the code insert in this post.

<?php

$where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

// File upload handling
if($_FILES['field_6']['name']!=''){
$field_6_filename = "file_6_".date("sihdmY").substr($_FILES['field_6']['name'],strlen($_FILES['field_6']['name'])-4);
if(!move_uploaded_file($_FILES['field_6']['tmp_name'], "./files/".$field_6_filename)){
die("File " .  $_FILES['field_6']['name'] . " was not uploaded.");
}
}

include("config.inc.php");
$link = mysql_connect($db_host,$db_user,$db_pass);
if(!$link) die ('Could not connect to database: '.mysql_error());
mysql_select_db($db_name,$link);
$query = "INSERT into `".$db_table."` (field_1,field_2,field_3,field_4,field_5,field_6,field_7,field_8,field_9,field_10,field_11,field_12,field_13,field_14) VALUES ('" . $_POST['field_1'] . "','" . $_POST['field_2'] . "','" . $_POST['field_3'] . "','" . $_POST['field_4'] . "','" . $_POST['field_5'] . "','" . $_POST['field_6'] . "','" . $_POST['field_7'] . "','" . $_POST['field_8'] . "','" . $_POST['field_9'] . "','" . $_POST['field_10'] . "','" . $_POST['field_11'] . "','" . $_POST['field_12'] . "','" . $_POST['field_13'] . "','" . $_POST['field_14'] . "')";
mysql_query($query);
mysql_close($link);

mail("","phpFormGenerator - Form submission","Form data:

Customer Name: " . $_POST['field_1'] . " 
Customer Email: " . $_POST['field_2'] . " 
Quantity: " . $_POST['field_3'] . " 
Size: " . $_POST['field_4'] . " 
Special Instructions: " . $_POST['field_5'] . " 
Upload Your Image Here: ".$where_form_is."files/".$field_6_filename." (original file name: " . $_FILES['field_6']['name'] . ")
Shipping Information: " . $_POST['field_7'] . " 
Ship to Address: " . $_POST['field_8'] . " 
Please read and check this option or your image will not be reproduced.: " . $_POST['field_9'] . " 
Alterations: " . $_POST['field_10'] . " 
: " . $_POST['field_11'] . " 
: " . $_POST['field_12'] . " 
: " . $_POST['field_13'] . " 
: " . $_POST['field_14'] . " 



");

$busmail = $_POST['field_2']

mail($busmail, "Order Confirmation","Your Order Has Been Received And Is Now Being Processed.

 
Quantity: " . $_POST['field_3'] . " 
Size: " . $_POST['field_4'] . " 
Special Instructions: " . $_POST['field_5'] . " 

Please contact us with any questions or concerns at <A href="mailto:c2c@capturedtocanvas.com" target=_top>c2c@capturedtocanvas.com</A> 
");

include("confirm.html");

?>


PHP Parse error: syntax error, unexpected T_STRING in /hermes/bosweb/web171/b1716/sl.c2cadmin/C2C/Form/processor.php on line 44

jjasoningram
Newbie Poster
12 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
 
$busmail = $_POST['field_2'];


you forgot the semi colon on this line.
line 42.

ryan_vietnow
Posting Pro
578 posts since Aug 2007
Reputation Points: 28
Solved Threads: 71
 

Ok Guys,
This is for you in particular, Ryan. Thanks for the help so far. I feel that this may be the last issue with the script.

<?php

$where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

// File upload handling
if($_FILES['field_6']['name']!=''){
$field_6_filename = "file_6_".date("sihdmY").substr($_FILES['field_6']['name'],strlen($_FILES['field_6']['name'])-4);
if(!move_uploaded_file($_FILES['field_6']['tmp_name'], "./files/".$field_6_filename)){
die("File " .  $_FILES['field_6']['name'] . " was not uploaded.");
}
}

include("config.inc.php");
$link = mysql_connect($db_host,$db_user,$db_pass);
if(!$link) die ('Could not connect to database: '.mysql_error());
mysql_select_db($db_name,$link);
$query = "INSERT into `".$db_table."` (field_1,field_2,field_3,field_4,field_5,field_6,field_7,field_8,field_9,field_10,field_11,field_12,field_13,field_14) VALUES ('" . $_POST['field_1'] . "','" . $_POST['field_2'] . "','" . $_POST['field_3'] . "','" . $_POST['field_4'] . "','" . $_POST['field_5'] . "','" . $_POST['field_6'] . "','" . $_POST['field_7'] . "','" . $_POST['field_8'] . "','" . $_POST['field_9'] . "','" . $_POST['field_10'] . "','" . $_POST['field_11'] . "','" . $_POST['field_12'] . "','" . $_POST['field_13'] . "','" . $_POST['field_14'] . "')";
mysql_query($query);
mysql_close($link);

mail("","phpFormGenerator - Form submission","Form data:

Customer Name: " . $_POST['field_1'] . " 
Customer Email: " . $_POST['field_2'] . " 
Quantity: " . $_POST['field_3'] . " 
Size: " . $_POST['field_4'] . " 
Special Instructions: " . $_POST['field_5'] . " 
Upload Your Image Here: ".$where_form_is."files/".$field_6_filename." (original file name: " . $_FILES['field_6']['name'] . ")
Shipping Information: " . $_POST['field_7'] . " 
Ship to Address: " . $_POST['field_8'] . " 
Please read and check this option or your image will not be reproduced.: " . $_POST['field_9'] . " 
Alterations: " . $_POST['field_10'] . " 
: " . $_POST['field_11'] . " 
: " . $_POST['field_12'] . " 
: " . $_POST['field_13'] . " 
: " . $_POST['field_14'] . " 



");

$busmail = $_POST['field_2'];

mail($busmail, "Order Confirmation","Your Order Has Been Received And Is Now Being Processed.

 
Quantity: " . $_POST['field_3'] . " 
Size: " . $_POST['field_4'] . " 
Special Instructions: " . $_POST['field_5'] . " 

Please contact us with any questions or concerns at <A href="mailto:c2c@capturedtocanvas.com" target=_top>c2c@capturedtocanvas.com</A> 
");

include("confirm.html");

?>

PHP Parse error: syntax error, unexpected T_STRING in /hermes/bosweb/web171/b1716/sl.c2cadmin/C2C/Form/processor.php on line 51

jjasoningram
Newbie Poster
12 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
 

change the double quote here:

<A href="mailto:c2c@capturedtocanvas.com" target=_top>c2c@capturedtocanvas.com</A>


to single quote:

<A href='mailto:c2c@capturedtocanvas.com' target=_top>c2c@capturedtocanvas.com</A>
ryan_vietnow
Posting Pro
578 posts since Aug 2007
Reputation Points: 28
Solved Threads: 71
 

or to keep proper html syntax you could do this:

<A href=\"mailto:c2c@capturedtocanvas.com\" target=_top>c2c@capturedtocanvas.com</A>
kkeith29
Nearly a Posting Virtuoso
1,357 posts since Jun 2007
Reputation Points: 235
Solved Threads: 194
 

Hey guys, I can't thank you enough. I appreciate all of the comments. I did figure out the last problem. I didn't have to put the HTML formatting on the link to the email. Most email programs automatically format a link by the way it is typed. I removed the format and got no more errors. When opening the email, the link was active. Thanks again for the help.

jjasoningram
Newbie Poster
12 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
 

I get this error:
PHP Parse error: parse error in D:\HostingSpaces\sachinbhatt\sachinbhatt.in\wwwroot\send_mail.php on line 73

The script is ..:

$Subject="New Inquiry";
$Message="Inquiry Details";
$Message.="Name: $FullName";
$Message.="Occupation: $Occupation";
$Message.="Address: $Address";
$Message.="City: $City";
$Message.="State: $State";
$Message.="Phone: $phone";
$Message.="Email: $Email";
$Message.="Comments: $Comments";
$Headers = "From: sbhatt.salil@sachinbhatt.in"."\r\n";
$Headers .= "MIME-Version: 1.0"."\r\n";
$Headers .= "Content-type: text/html; charset=iso-8859-1"."\r\n";
$Headers .= "Content-Transfer-Encoding: 7bit"."\r\n";
$r=mail("sbhatt.salil@sachinbhatt.in",$Subject,$Message,$Headers));

if(!empty($r)){
	//header("Location:ty.html");
	echo("&status=yes");
}
else{
	echo("&status=no");
}

----------------------------------------
I am not very proficient in PHP and I have not written this script as well, but using by copy/paste from some online resource.
Can anyone please help me with this..?
Many thanks in advance...

sachinbhatt
Newbie Poster
2 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

I get this error: PHP Parse error: parse error in D:\HostingSpaces\sachinbhatt\sachinbhatt.in\wwwroot\send_mail.php on line 73

The script is ..:

$Subject="New Inquiry";
$Message="Inquiry Details";
$Message.="Name: $FullName";
$Message.="Occupation: $Occupation";
$Message.="Address: $Address";
$Message.="City: $City";
$Message.="State: $State";
$Message.="Phone: $phone";
$Message.="Email: $Email";
$Message.="Comments: $Comments";
$Headers = "From: sbhatt.salil@sachinbhatt.in"."\r\n";
$Headers .= "MIME-Version: 1.0"."\r\n";
$Headers .= "Content-type: text/html; charset=iso-8859-1"."\r\n";
$Headers .= "Content-Transfer-Encoding: 7bit"."\r\n";
$r=mail("sbhatt.salil@sachinbhatt.in",$Subject,$Message,$Headers));

if(!empty($r)){
	//header("Location:ty.html");
	echo("&status=yes");
}
else{
	echo("&status=no");
}

---------------------------------------- I am not very proficient in PHP and I have not written this script as well, but using by copy/paste from some online resource. Can anyone please help me with this..? Many thanks in advance...

First of all, get a good editor which error checking. If you do, you will see the error yourself.
Anyways, You have an extra) in your mail function.

Next time, please start a new thread while posting a question.

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

The minute I submitted my post I re-checked the line and ......
Oops....
I found where I was going wrong..!!

in line 15:
$r=mail("sbhatt.salil@sachinbhatt.in",$Subject,$Message,$Headers));
I placed an extra.. ' ) '...! :)

Anyway.. Thanks nav33n.
Sure I will follow your guidelines. :)
Regards,
-Sachin.

sachinbhatt
Newbie Poster
2 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

Yep! Cheers :)

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You