By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,979 Members | 943 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,979 IT Pros & Developers. It's quick & easy.

Parse error: syntax error, unexpected T_SL in /home2/exoduses/public_html/phptest.php

P: 5
Hi,
I was wondering if anyone could help me. This site is for college, and I have everything else working, except for this PHP thingy. This is the error message I get:

Parse error: syntax error, unexpected T_SL in /home2/exoduses/public_html/phptest.php on line 16

----------------------------------------------------------------------------------------------------------------------

And this is my PHP code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3.  
  4. echo 'code tags!';
  5.  
  6.  
  7. /* subject and email variables */
  8.  
  9.         $emailSubject =  'Crazy PHP Scripting!';
  10.         $WebMaster = '__MUNGED__';
  11.  
  12.  
  13. /* Gathering Data Variables */
  14.  
  15.         $emailField = $_POST['email'];    
  16.         $nameField = $_POST['name'];    
  17.         $commentsField = $_POST['comments'];
  18.  
  19.  
  20.         $body = <<<'EOD'        
  21. <br><hr><br>
  22. Email: $emailField <br>
  23. Name: $nameField <br>
  24. Comments: $commentsField <br>
  25. EOD; 
  26.  
  27.     $headers = "From: $email\r\n";
  28.     $headers .= "Content-type: text/html\r\n";    
  29.     $success = mail($WebMaster, $emailSubject, $body, $headers);
  30.  
  31.  
  32. /* results rendered as html*/
  33.  
  34.     $theResults = <<<'EOD'
  35. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  36. <html xmlns="http://www.w3.org/1999/xhtml">
  37. <head>
  38. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  39. <title>Untitled Document</title>
  40. <link href="site.css" rel="stylesheet" type="text/css" />
  41. </head>
  42.  
  43. <body>
  44. <p>Congratulations! Your Message was sent!</p>
  45. <p>click <a href="homepage.html">here</a> to return to the mainpage</p>
  46. </body>
  47. </html>    
  48. EOD;
  49. echo "$theResults";
  50.  
  51.  
  52. ?>
  53.  
------------------------------------------------------------------------------------------------------------------
Any help would be much appreciated!

Thanks in advance,
Jay
Aug 19 '08 #1
Share this Question
Share on Google+
9 Replies


Markus
Expert 5K+
P: 6,050
Hi there, Exoduses. Welcome to the forums!

Just to get you started, when you post code in the forum please wrap it in CODE tags.

Example:
[CODE]
<?php
echo 'code tags!';
?>
[/CODE]

It makes things alot easier to read. It also gives line numbers to the code, which, in your case, helps a great deal - if you had used code tags, I wouldn't've had to copy the code into my texteditor to find the linenumber!
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     echo 'code tags'!;
  3. ?>
  4.  
Now to your problem: remove the quotes from the EOD.
Aug 19 '08 #2

P: 5
Thankyou!

I've changed it, and now when I click send, all I get is a white page, with this in the address bar:

http://example.com/phptest.php?email...=Send+Email%21

And it doesn't change :s

I don't know if my echo results code was right.

Jay
Aug 19 '08 #3

pbmods
Expert 5K+
P: 5,821
Heya, Jay.

NOWDOC syntax is available as of PHP 5.3, but that's still in alpha. What version of PHP are you running?

Which line is causing the error?
Aug 19 '08 #4

P: 5
Hi,

I don't have a clue what version lol. Sorry. There's no error message displayed.

The link to the contact page, so you can see the error for yourself, is

Contact Us Page


I really feel like a noob lol

Jay
Aug 20 '08 #5

Markus
Expert 5K+
P: 6,050
As I said on msn: there is no 'method' attribute on your form. Therefore, the results are sent via GET and not POST, which is what you are trying to retrieve the data by.
Aug 20 '08 #6

pbmods
Expert 5K+
P: 5,821
Which line in your code is actually causing the error? Please repost the code around the line that the error mentions.
Aug 20 '08 #7

P: 5
It doesn't display a message of any kind.

The code is:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. /* subject and email variables */
  4.  
  5.         $emailSubject =  'Crazy PHP Scripting!';
  6.         $webMaster = 'webmaster@phptestfortazsite.xf-s.com';
  7.  
  8.  
  9. /* Gathering Data Variables */
  10.  
  11. // check the POSTed data
  12. if(isset($_POST['email']) && isset($_POST['name']) isset($_POST['comments']) {
  13.       $emailField = $_POST['email'];   
  14.       $nameField = $_POST['name'];   
  15.       $commentsField = $_POST['comments'];
  16. }
  17.  
  18. // fix up the variables in the heredoc
  19. $body = <<<EOD
  20. Email: {$email}
  21.  
  22. Name:{$name}
  23.  
  24. Comments: {$comments}
  25.  
  26. EOD;
  27.  
  28.  
  29.         $body = <<<EOD
  30. <br><hr><br>
  31. Email: $email <br>
  32. Name: $name <br>
  33. Comments: $comments <br>
  34. EOD; 
  35.  
  36.     $headers = "From: $email\r\n";
  37.     $headers .= "Content-type: text/html\r\n";    
  38.     $success = mail($webMaster, $emailSubject, $body, $headers);
  39.  
  40.  
  41. /* results rendered as HTML*/
  42.  
  43.     $theResults = <<<EOD
  44. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  45. <html xmlns="http://www.w3.org/1999/xhtml">
  46. <head>
  47. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  48. <title>Untitled Document</title>
  49. <link href="site.css" rel="stylesheet" type="text/css" />
  50. </head>
  51.  
  52. <body>
  53. <p>Congratulations! Your mail was sent!</p>
  54. <p>click <a href="homepage.html">here</a> to return to the mainpage</p>
  55. </body>
  56. </html>    
  57. EOD;
  58. echo "$theResults";
  59.  
  60. <html>
  61. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  62. <html xmlns="http://www.w3.org/1999/xhtml">
  63. <head>
  64. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  65. <title>Untitled Document</title>
  66. <link href="site.css" rel="stylesheet" type="text/css" />
  67. <style type="text/css">
  68. <!--
  69. .style1 {color: #0066CC}
  70. -->
  71. </style>
  72. </head>
  73.  
  74. <body>
  75. <table width="100%" border="0">
  76.   <tr>
  77.     <th scope="col"><a href="homepage.html">Homepage</a></th>
  78.     <th scope="col"><a href="WhatisNinjitsu.html">What Is Ninjitsu?</a></th>
  79.     <th scope="col"><a href="WeaponsClothing.html">Weapons / Clothing</a></th>
  80.     <th scope="col"><a href="Media.html">Media</a></th>
  81.     <th scope="col"><a href="ContactUs.html">Contact Us</a></th>
  82.   </tr>
  83. </table>
  84. <p>&nbsp;</p>
  85. <form action="phptest.php" name="form1" id="form1">
  86.   <table width="100%" border="0" cellspacing="0" cellpadding="6">
  87.     <tr>
  88.       <td bgcolor="#000000"><label for="email">
  89.           <div align="right" class="style1">Email Address:</div>
  90.         </label>
  91.       </td>
  92.       <td bgcolor="#000000"><div align="left">
  93.         <input name="email" type="text" id="email" size="35" maxlength="100" />
  94.       </div></td>
  95.     </tr>
  96.     <tr>
  97.       <td bgcolor="#000000"><label for="name">
  98.           <div align="right"><span class="style1">Name</span>:</div>
  99.         </label>
  100.       </td>
  101.       <td bgcolor="#000000"><div align="left">
  102.         <input name="name" type="text" id="name" size="35" maxlength="80" />
  103.       </div></td>
  104.     </tr>
  105.     <tr>
  106.       <td bgcolor="#000000"><label for="phone"> </label>
  107.           <label for="label"></label>
  108.           <div align="right">
  109.             <label for="label"></label>
  110.             <label for="label"><span class="style1">Comments</span>:</label>
  111.         </div></td>
  112.       <td bgcolor="#000000"><textarea name="comments" id="comments" cols="26" rows="5"></textarea></td>
  113.     </tr>
  114.     <tr>
  115.       <td bgcolor="#000000">&nbsp;</td>
  116.       <td bgcolor="#000000"><p align="left">
  117.         <label></label>
  118.         <br />
  119.       </p></td>
  120.     </tr>
  121.     <tr>
  122.       <td bgcolor="#000000"><div align="right">
  123.         <label for="clear"></label>
  124.         <input type="reset" name="clear" id="clear" value="Reset Form" />
  125.       </div></td>
  126.       <td bgcolor="#000000"><div align="right">
  127.         <label for="submit"></label>
  128.         <div align="left">
  129.           <input type="submit" name="Submit" id="submit" value="Send Email!" />
  130.         </div>
  131.       </div></td>
  132.     </tr>
  133.   </table>
  134. </form>
  135. <p>&nbsp;</p>
  136. </body>
  137. </html>
  138.  
  139. <html>
  140. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  141. <html xmlns="http://www.w3.org/1999/xhtml">
  142. <head>
  143. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  144. <title>Untitled Document</title>
  145. <link href="site.css" rel="stylesheet" type="text/css" />
  146. <style type="text/css">
  147. <!--
  148. .style1 {color: #0066CC}
  149. -->
  150. </style>
  151. </head>
  152.  
  153. <body>
  154. <table width="100%" border="0">
  155.   <tr>
  156.     <th scope="col"><a href="homepage.html">Homepage</a></th>
  157.     <th scope="col"><a href="WhatisNinjitsu.html">What Is Ninjitsu?</a></th>
  158.     <th scope="col"><a href="WeaponsClothing.html">Weapons / Clothing</a></th>
  159.     <th scope="col"><a href="Media.html">Media</a></th>
  160.     <th scope="col"><a href="ContactUs.html">Contact Us</a></th>
  161.   </tr>
  162. </table>
  163. <p>&nbsp;</p>
  164. <form action="phptest.php" name="form1" id="form1">
  165.   <table width="100%" border="0" cellspacing="0" cellpadding="6">
  166.     <tr>
  167.       <td bgcolor="#000000"><label for="email">
  168.           <div align="right" class="style1">Email Address:</div>
  169.         </label>
  170.       </td>
  171.       <td bgcolor="#000000"><div align="left">
  172.         <input name="email" type="text" id="email" size="35" maxlength="100" />
  173.       </div></td>
  174.     </tr>
  175.     <tr>
  176.       <td bgcolor="#000000"><label for="name">
  177.           <div align="right"><span class="style1">Name</span>:</div>
  178.         </label>
  179.       </td>
  180.       <td bgcolor="#000000"><div align="left">
  181.         <input name="name" type="text" id="name" size="35" maxlength="80" />
  182.       </div></td>
  183.     </tr>
  184.     <tr>
  185.       <td bgcolor="#000000"><label for="phone"> </label>
  186.           <label for="label"></label>
  187.           <div align="right">
  188.             <label for="label"></label>
  189.             <label for="label"><span class="style1">Comments</span>:</label>
  190.         </div></td>
  191.       <td bgcolor="#000000"><textarea name="comments" id="comments" cols="26" rows="5"></textarea></td>
  192.     </tr>
  193.     <tr>
  194.       <td bgcolor="#000000">&nbsp;</td>
  195.       <td bgcolor="#000000"><p align="left">
  196.         <label></label>
  197.         <br />
  198.       </p></td>
  199.     </tr>
  200.     <tr>
  201.       <td bgcolor="#000000"><div align="right">
  202.         <label for="clear"></label>
  203.         <input type="reset" name="clear" id="clear" value="Reset Form" />
  204.       </div></td>
  205.       <td bgcolor="#000000"><div align="right">
  206.         <label for="submit"></label>
  207.         <div align="left">
  208.           <input type="submit" name="Submit" id="submit" value="Send Email!" />
  209.         </div>
  210.       </div></td>
  211.     </tr>
  212.   </table>
  213. </form>
  214. <p>&nbsp;</p>
  215. </body>
  216. </html>
  217. ?>
  218.  
  219.  
  220.  
After I click send on the contact page, it appears to be loading the next page, however, it just stays white. I really am confused. I am sorry about this.

Jay

Also, this code, has been done by my friend, who is making the site with me.
Aug 21 '08 #8

pbmods
Expert 5K+
P: 5,821
Make sure you have display_errors turned on (http://bytes.com/forum/thread629295.html).
Aug 22 '08 #9

P: 5
Okay, this is the lastest code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. error_reporting(E_ALL);
  3. ini_set('display_errors', true);
  4. /* subject and email variables */
  5.  
  6.         $emailSubject =  'Crazy PHP Scripting!';
  7.         $WebMaster = 'webmaster@phptestfortazsite.xf-s.com';
  8.  
  9.  
  10. /* Gathering Data Variables */
  11.  
  12.         $emailField = $_POST['email'];    
  13.         $nameField = $_POST['name'];    
  14.         $commentsField = $_POST['comments'];
  15.  
  16.  
  17.         $body = <<<EOD
  18. <br><hr><br>
  19. Email: $emailField <br>
  20. Name: $nameField <br>
  21. Comments: $commentsField <br>
  22. EOD; 
  23.  
  24.     $headers = "From: $emailField\r\n";
  25.     $headers = "Content-type: text/html\r\n";    
  26.     $success = mail($WebMaster, $emailSubject, $body, $headers);
  27.  
  28.  
  29. /* results rendered as html*/
  30.  
  31.     $theResults = <<<EOD
  32. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  33. <html xmlns="http://www.w3.org/1999/xhtml">
  34. <head>
  35. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  36. <title>Sucess</title>
  37. <link href="site.css" rel="stylesheet" type="text/css" />
  38. </head>
  39.  
  40. <body>
  41. <p>Congratulations! Your Message was sent!</p>
  42. <p>click <a href="homepage.html">here</a> to return to the mainpage</p>
  43. </body>
  44. </html>    
  45. EOD;
  46. echo "$theResults";
  47.  
  48. ?>
  49.  
and this is the error message I'm getting. I'm still really confused by it all :s

Expand|Select|Wrap|Line Numbers
  1.  
  2. Notice: Undefined variable: headers in /home2/exoduses/public_html/phptest.php on line 25
  3.  
  4. Notice: Undefined variable: headers in /home2/exoduses/public_html/phptest.php on line 27
  5.  
  6. Notice: Undefined variable: success in /home2/exoduses/public_html/phptest.php on line 27
  7.  
  8. Notice: Undefined variable: body in /home2/exoduses/public_html/phptest.php on line 27
  9.  
  10. Notice: Undefined variable: headers in /home2/exoduses/public_html/phptest.php on line 32
  11.  
  12. Notice: Undefined variable: theResults in /home2/exoduses/public_html/phptest.php on line 45
  13.  
  14. Notice: Undefined variable: theResults in /home2/exoduses/public_html/phptest.php on line 47
  15.  
Jay
Aug 22 '08 #10

Post your reply

Sign in to post your reply or Sign up for a free account.