943,844 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 2998
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Mar 6th, 2008
0

Mail Function syntax error

Expand Post »
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:

php Syntax (Toggle Plain Text)
  1. $busmail = $_POST['field_2']
  2.  
  3. mail(" . $busmail . ","Order Confirmation","Your Order Has Been Received And Is Now Being Processed.
  4.  
  5.  
  6. Quantity: " . $_POST['field_3'] . "
  7. Size: " . $_POST['field_4'] . "
  8. Special Instructions: " . $_POST['field_5'] . "
  9.  
  10. Please contact us with any questions or concerns at <A href="mailto:c2c@capturedtocanvas.com" target=_top>c2c@capturedtocanvas.com</A>
  11. ");

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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jjasoningram is offline Offline
12 posts
since Feb 2008
Mar 6th, 2008
0

Re: Mail Function syntax error

Here is the entire script so you can see which line is 44.
php Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));
  4.  
  5. // File upload handling
  6. if($_FILES['field_6']['name']!=''){
  7. $field_6_filename = "file_6_".date("sihdmY").substr($_FILES['field_6']['name'],strlen($_FILES['field_6']['name'])-4);
  8. if(!move_uploaded_file($_FILES['field_6']['tmp_name'], "./files/".$field_6_filename)){
  9. die("File " . $_FILES['field_6']['name'] . " was not uploaded.");
  10. }
  11. }
  12.  
  13. include("config.inc.php");
  14. $link = mysql_connect($db_host,$db_user,$db_pass);
  15. if(!$link) die ('Could not connect to database: '.mysql_error());
  16. mysql_select_db($db_name,$link);
  17. $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'] . "')";
  18. mysql_query($query);
  19. mysql_close($link);
  20.  
  21. mail("","phpFormGenerator - Form submission","Form data:
  22.  
  23. Customer Name: " . $_POST['field_1'] . "
  24. Customer Email: " . $_POST['field_2'] . "
  25. Quantity: " . $_POST['field_3'] . "
  26. Size: " . $_POST['field_4'] . "
  27. Special Instructions: " . $_POST['field_5'] . "
  28. Upload Your Image Here: ".$where_form_is."files/".$field_6_filename." (original file name: " . $_FILES['field_6']['name'] . ")
  29. Shipping Information: " . $_POST['field_7'] . "
  30. Ship to Address: " . $_POST['field_8'] . "
  31. Please read and check this option or your image will not be reproduced.: " . $_POST['field_9'] . "
  32. Alterations: " . $_POST['field_10'] . "
  33. : " . $_POST['field_11'] . "
  34. : " . $_POST['field_12'] . "
  35. : " . $_POST['field_13'] . "
  36. : " . $_POST['field_14'] . "
  37.  
  38.  
  39.  
  40. ");
  41.  
  42. $busmail = $_POST['field_2']
  43.  
  44. mail(" . $busmail . ","Order Confirmation","Your Order Has Been Received And Is Now Being Processed.
  45.  
  46.  
  47. Quantity: " . $_POST['field_3'] . "
  48. Size: " . $_POST['field_4'] . "
  49. Special Instructions: " . $_POST['field_5'] . "
  50.  
  51. Please contact us with any questions or concerns at <A href="mailto:c2c@capturedtocanvas.com" target=_top>c2c@capturedtocanvas.com</A>
  52. ");
  53.  
  54. include("confirm.html");
  55.  
  56. ?>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jjasoningram is offline Offline
12 posts
since Feb 2008
Mar 6th, 2008
0

Re: Mail Function syntax error

PHP Syntax (Toggle Plain Text)
  1. mail(" . $busmail . ","Order Confirmation","Your Order Has Been Received And Is Now Being Processed.
  2.  

needs to be

PHP Syntax (Toggle Plain Text)
  1. mail($busmail, "Order Confirmation","Your Order Has Been Received And Is Now Being Processed.
  2.  
Reputation Points: 16
Solved Threads: 16
Junior Poster
Auzzie is offline Offline
121 posts
since Nov 2007
Mar 6th, 2008
0

Re: Mail Function syntax error

yeah,no need for the quotes because it is only a variable.
Reputation Points: 28
Solved Threads: 71
Posting Pro
ryan_vietnow is offline Offline
578 posts
since Aug 2007
Mar 6th, 2008
0

Re: Mail Function syntax error

Plus the quotes wernt closed off to allow for the string concantation
Reputation Points: 16
Solved Threads: 16
Junior Poster
Auzzie is offline Offline
121 posts
since Nov 2007
Mar 6th, 2008
0

Re: Mail Function syntax error

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

php Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));
  4.  
  5. // File upload handling
  6. if($_FILES['field_6']['name']!=''){
  7. $field_6_filename = "file_6_".date("sihdmY").substr($_FILES['field_6']['name'],strlen($_FILES['field_6']['name'])-4);
  8. if(!move_uploaded_file($_FILES['field_6']['tmp_name'], "./files/".$field_6_filename)){
  9. die("File " . $_FILES['field_6']['name'] . " was not uploaded.");
  10. }
  11. }
  12.  
  13. include("config.inc.php");
  14. $link = mysql_connect($db_host,$db_user,$db_pass);
  15. if(!$link) die ('Could not connect to database: '.mysql_error());
  16. mysql_select_db($db_name,$link);
  17. $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'] . "')";
  18. mysql_query($query);
  19. mysql_close($link);
  20.  
  21. mail("","phpFormGenerator - Form submission","Form data:
  22.  
  23. Customer Name: " . $_POST['field_1'] . "
  24. Customer Email: " . $_POST['field_2'] . "
  25. Quantity: " . $_POST['field_3'] . "
  26. Size: " . $_POST['field_4'] . "
  27. Special Instructions: " . $_POST['field_5'] . "
  28. Upload Your Image Here: ".$where_form_is."files/".$field_6_filename." (original file name: " . $_FILES['field_6']['name'] . ")
  29. Shipping Information: " . $_POST['field_7'] . "
  30. Ship to Address: " . $_POST['field_8'] . "
  31. Please read and check this option or your image will not be reproduced.: " . $_POST['field_9'] . "
  32. Alterations: " . $_POST['field_10'] . "
  33. : " . $_POST['field_11'] . "
  34. : " . $_POST['field_12'] . "
  35. : " . $_POST['field_13'] . "
  36. : " . $_POST['field_14'] . "
  37.  
  38.  
  39.  
  40. ");
  41.  
  42. $busmail = $_POST['field_2']
  43.  
  44. mail($busmail, "Order Confirmation","Your Order Has Been Received And Is Now Being Processed.
  45.  
  46.  
  47. Quantity: " . $_POST['field_3'] . "
  48. Size: " . $_POST['field_4'] . "
  49. Special Instructions: " . $_POST['field_5'] . "
  50.  
  51. Please contact us with any questions or concerns at <A href="mailto:c2c@capturedtocanvas.com" target=_top>c2c@capturedtocanvas.com</A>
  52. ");
  53.  
  54. include("confirm.html");
  55.  
  56. ?>

PHP Parse error: syntax error, unexpected T_STRING in /hermes/bosweb/web171/b1716/sl.c2cadmin/C2C/Form/processor.php on line 44
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jjasoningram is offline Offline
12 posts
since Feb 2008
Mar 6th, 2008
0

Re: Mail Function syntax error

php Syntax (Toggle Plain Text)
  1. $busmail = $_POST['field_2'];

you forgot the semi colon on this line.
line 42.
Reputation Points: 28
Solved Threads: 71
Posting Pro
ryan_vietnow is offline Offline
578 posts
since Aug 2007
Mar 6th, 2008
0

Re: Mail Function syntax error

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 Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));
  4.  
  5. // File upload handling
  6. if($_FILES['field_6']['name']!=''){
  7. $field_6_filename = "file_6_".date("sihdmY").substr($_FILES['field_6']['name'],strlen($_FILES['field_6']['name'])-4);
  8. if(!move_uploaded_file($_FILES['field_6']['tmp_name'], "./files/".$field_6_filename)){
  9. die("File " . $_FILES['field_6']['name'] . " was not uploaded.");
  10. }
  11. }
  12.  
  13. include("config.inc.php");
  14. $link = mysql_connect($db_host,$db_user,$db_pass);
  15. if(!$link) die ('Could not connect to database: '.mysql_error());
  16. mysql_select_db($db_name,$link);
  17. $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'] . "')";
  18. mysql_query($query);
  19. mysql_close($link);
  20.  
  21. mail("","phpFormGenerator - Form submission","Form data:
  22.  
  23. Customer Name: " . $_POST['field_1'] . "
  24. Customer Email: " . $_POST['field_2'] . "
  25. Quantity: " . $_POST['field_3'] . "
  26. Size: " . $_POST['field_4'] . "
  27. Special Instructions: " . $_POST['field_5'] . "
  28. Upload Your Image Here: ".$where_form_is."files/".$field_6_filename." (original file name: " . $_FILES['field_6']['name'] . ")
  29. Shipping Information: " . $_POST['field_7'] . "
  30. Ship to Address: " . $_POST['field_8'] . "
  31. Please read and check this option or your image will not be reproduced.: " . $_POST['field_9'] . "
  32. Alterations: " . $_POST['field_10'] . "
  33. : " . $_POST['field_11'] . "
  34. : " . $_POST['field_12'] . "
  35. : " . $_POST['field_13'] . "
  36. : " . $_POST['field_14'] . "
  37.  
  38.  
  39.  
  40. ");
  41.  
  42. $busmail = $_POST['field_2'];
  43.  
  44. mail($busmail, "Order Confirmation","Your Order Has Been Received And Is Now Being Processed.
  45.  
  46.  
  47. Quantity: " . $_POST['field_3'] . "
  48. Size: " . $_POST['field_4'] . "
  49. Special Instructions: " . $_POST['field_5'] . "
  50.  
  51. Please contact us with any questions or concerns at <A href="mailto:c2c@capturedtocanvas.com" target=_top>c2c@capturedtocanvas.com</A>
  52. ");
  53.  
  54. include("confirm.html");
  55.  
  56. ?>
PHP Parse error: syntax error, unexpected T_STRING in /hermes/bosweb/web171/b1716/sl.c2cadmin/C2C/Form/processor.php on line 51
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jjasoningram is offline Offline
12 posts
since Feb 2008
Mar 6th, 2008
0

Re: Mail Function syntax error

change the double quote here:

php Syntax (Toggle Plain Text)
  1. <A href="mailto:c2c@capturedtocanvas.com" target=_top>c2c@capturedtocanvas.com</A>

to single quote:

php Syntax (Toggle Plain Text)
  1. <A href='mailto:c2c@capturedtocanvas.com' target=_top>c2c@capturedtocanvas.com</A>
Reputation Points: 28
Solved Threads: 71
Posting Pro
ryan_vietnow is offline Offline
578 posts
since Aug 2007
Mar 6th, 2008
0

Re: Mail Function syntax error

or to keep proper html syntax you could do this:

PHP Syntax (Toggle Plain Text)
  1. <A href=\"mailto:c2c@capturedtocanvas.com\" target=_top>c2c@capturedtocanvas.com</A>
  2.  
Last edited by kkeith29; Mar 6th, 2008 at 10:34 pm.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Getting PHP to ignore blank spaces and capitalization on a text field in a form?
Next Thread in PHP Forum Timeline: php with mysql





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC