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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • exoduses
    New Member
    • Aug 2008
    • 5

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

    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:
    Code:
    [I]<?php
    
    
    echo 'code tags!';
    
    
    /* subject and email variables */
    
    		$emailSubject =  'Crazy PHP Scripting!';
    		$WebMaster = '__MUNGED__';
    		
    		
    /* Gathering Data Variables */
    
    		$emailField = $_POST['email'];	
    		$nameField = $_POST['name'];	
    		$commentsField = $_POST['comments'];
    		
    		
    		$body = <<<'EOD'		
    <br><hr><br>
    Email: $emailField <br>
    Name: $nameField <br>
    Comments: $commentsField <br>
    EOD; 
    
    	$headers = "From: $email\r\n";
    	$headers .= "Content-type: text/html\r\n";	
    	$success = mail($WebMaster, $emailSubject, $body, $headers);
    	
    	  	
    /* results rendered as html*/
    
    	$theResults = <<<'EOD'
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <link href="site.css" rel="stylesheet" type="text/css" />
    </head>
    
    <body>
    <p>Congratulations! Your Message was sent!</p>
    <p>click <a href="homepage.html">here</a> to return to the mainpage</p>
    </body>
    </html>	
    EOD;
    echo "$theResults";
    
    
    ?>[/I]
    ------------------------------------------------------------------------------------------------------------------
    Any help would be much appreciated!

    Thanks in advance,
    Jay
    Last edited by pbmods; Aug 19 '08, 10:18 PM. Reason: Removed email.
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    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!
    Code:
    <?php
        echo 'code tags'!;
    ?>
    Now to your problem: remove the quotes from the EOD.

    Comment

    • exoduses
      New Member
      • Aug 2008
      • 5

      #3
      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
      Last edited by Atli; Aug 20 '08, 11:25 AM. Reason: Replaced real URL and email with example values.

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        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?

        Comment

        • exoduses
          New Member
          • Aug 2008
          • 5

          #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
          Last edited by exoduses; Aug 20 '08, 01:38 PM. Reason: Changed the link to an actual link

          Comment

          • Markus
            Recognized Expert Expert
            • Jun 2007
            • 6092

            #6
            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.

            Comment

            • pbmods
              Recognized Expert Expert
              • Apr 2007
              • 5821

              #7
              Which line in your code is actually causing the error? Please repost the code around the line that the error mentions.

              Comment

              • exoduses
                New Member
                • Aug 2008
                • 5

                #8
                It doesn't display a message of any kind.

                The code is:

                Code:
                <?php
                
                /* subject and email variables */
                
                		$emailSubject =  'Crazy PHP Scripting!';
                		$webMaster = 'webmaster@phptestfortazsite.xf-s.com';
                		
                		
                /* Gathering Data Variables */
                
                // check the POSTed data
                if(isset($_POST['email']) && isset($_POST['name']) isset($_POST['comments']) {
                      $emailField = $_POST['email'];   
                      $nameField = $_POST['name'];   
                      $commentsField = $_POST['comments'];
                }
                
                // fix up the variables in the heredoc
                $body = <<<EOD
                Email: {$email}
                
                Name:{$name}
                
                Comments: {$comments}
                
                EOD;
                		
                		
                		$body = <<<EOD
                <br><hr><br>
                Email: $email <br>
                Name: $name <br>
                Comments: $comments <br>
                EOD; 
                
                	$headers = "From: $email\r\n";
                	$headers .= "Content-type: text/html\r\n";	
                	$success = mail($webMaster, $emailSubject, $body, $headers);
                	
                	  	
                /* results rendered as HTML*/
                
                	$theResults = <<<EOD
                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                <html xmlns="http://www.w3.org/1999/xhtml">
                <head>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                <title>Untitled Document</title>
                <link href="site.css" rel="stylesheet" type="text/css" />
                </head>
                
                <body>
                <p>Congratulations! Your mail was sent!</p>
                <p>click <a href="homepage.html">here</a> to return to the mainpage</p>
                </body>
                </html>	
                EOD;
                echo "$theResults";
                
                <html>
                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                <html xmlns="http://www.w3.org/1999/xhtml">
                <head>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                <title>Untitled Document</title>
                <link href="site.css" rel="stylesheet" type="text/css" />
                <style type="text/css">
                <!--
                .style1 {color: #0066CC}
                -->
                </style>
                </head>
                
                <body>
                <table width="100%" border="0">
                  <tr>
                    <th scope="col"><a href="homepage.html">Homepage</a></th>
                    <th scope="col"><a href="WhatisNinjitsu.html">What Is Ninjitsu?</a></th>
                    <th scope="col"><a href="WeaponsClothing.html">Weapons / Clothing</a></th>
                    <th scope="col"><a href="Media.html">Media</a></th>
                    <th scope="col"><a href="ContactUs.html">Contact Us</a></th>
                  </tr>
                </table>
                <p>&nbsp;</p>
                <form action="phptest.php" name="form1" id="form1">
                  <table width="100%" border="0" cellspacing="0" cellpadding="6">
                    <tr>
                      <td bgcolor="#000000"><label for="email">
                          <div align="right" class="style1">Email Address:</div>
                        </label>
                      </td>
                      <td bgcolor="#000000"><div align="left">
                        <input name="email" type="text" id="email" size="35" maxlength="100" />
                      </div></td>
                    </tr>
                    <tr>
                      <td bgcolor="#000000"><label for="name">
                          <div align="right"><span class="style1">Name</span>:</div>
                        </label>
                      </td>
                      <td bgcolor="#000000"><div align="left">
                        <input name="name" type="text" id="name" size="35" maxlength="80" />
                      </div></td>
                    </tr>
                    <tr>
                      <td bgcolor="#000000"><label for="phone"> </label>
                          <label for="label"></label>
                          <div align="right">
                            <label for="label"></label>
                            <label for="label"><span class="style1">Comments</span>:</label>
                        </div></td>
                      <td bgcolor="#000000"><textarea name="comments" id="comments" cols="26" rows="5"></textarea></td>
                    </tr>
                    <tr>
                      <td bgcolor="#000000">&nbsp;</td>
                      <td bgcolor="#000000"><p align="left">
                        <label></label>
                        <br />
                      </p></td>
                    </tr>
                    <tr>
                      <td bgcolor="#000000"><div align="right">
                        <label for="clear"></label>
                        <input type="reset" name="clear" id="clear" value="Reset Form" />
                      </div></td>
                      <td bgcolor="#000000"><div align="right">
                        <label for="submit"></label>
                        <div align="left">
                          <input type="submit" name="Submit" id="submit" value="Send Email!" />
                        </div>
                      </div></td>
                    </tr>
                  </table>
                </form>
                <p>&nbsp;</p>
                </body>
                </html>
                
                <html>
                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                <html xmlns="http://www.w3.org/1999/xhtml">
                <head>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                <title>Untitled Document</title>
                <link href="site.css" rel="stylesheet" type="text/css" />
                <style type="text/css">
                <!--
                .style1 {color: #0066CC}
                -->
                </style>
                </head>
                
                <body>
                <table width="100%" border="0">
                  <tr>
                    <th scope="col"><a href="homepage.html">Homepage</a></th>
                    <th scope="col"><a href="WhatisNinjitsu.html">What Is Ninjitsu?</a></th>
                    <th scope="col"><a href="WeaponsClothing.html">Weapons / Clothing</a></th>
                    <th scope="col"><a href="Media.html">Media</a></th>
                    <th scope="col"><a href="ContactUs.html">Contact Us</a></th>
                  </tr>
                </table>
                <p>&nbsp;</p>
                <form action="phptest.php" name="form1" id="form1">
                  <table width="100%" border="0" cellspacing="0" cellpadding="6">
                    <tr>
                      <td bgcolor="#000000"><label for="email">
                          <div align="right" class="style1">Email Address:</div>
                        </label>
                      </td>
                      <td bgcolor="#000000"><div align="left">
                        <input name="email" type="text" id="email" size="35" maxlength="100" />
                      </div></td>
                    </tr>
                    <tr>
                      <td bgcolor="#000000"><label for="name">
                          <div align="right"><span class="style1">Name</span>:</div>
                        </label>
                      </td>
                      <td bgcolor="#000000"><div align="left">
                        <input name="name" type="text" id="name" size="35" maxlength="80" />
                      </div></td>
                    </tr>
                    <tr>
                      <td bgcolor="#000000"><label for="phone"> </label>
                          <label for="label"></label>
                          <div align="right">
                            <label for="label"></label>
                            <label for="label"><span class="style1">Comments</span>:</label>
                        </div></td>
                      <td bgcolor="#000000"><textarea name="comments" id="comments" cols="26" rows="5"></textarea></td>
                    </tr>
                    <tr>
                      <td bgcolor="#000000">&nbsp;</td>
                      <td bgcolor="#000000"><p align="left">
                        <label></label>
                        <br />
                      </p></td>
                    </tr>
                    <tr>
                      <td bgcolor="#000000"><div align="right">
                        <label for="clear"></label>
                        <input type="reset" name="clear" id="clear" value="Reset Form" />
                      </div></td>
                      <td bgcolor="#000000"><div align="right">
                        <label for="submit"></label>
                        <div align="left">
                          <input type="submit" name="Submit" id="submit" value="Send Email!" />
                        </div>
                      </div></td>
                    </tr>
                  </table>
                </form>
                <p>&nbsp;</p>
                </body>
                </html>
                ?>
                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.
                Last edited by exoduses; Aug 21 '08, 09:30 PM. Reason: Added more information

                Comment

                • pbmods
                  Recognized Expert Expert
                  • Apr 2007
                  • 5821

                  #9
                  Make sure you have display_errors turned on (http://bytes.com/forum/thread629295.html).

                  Comment

                  • exoduses
                    New Member
                    • Aug 2008
                    • 5

                    #10
                    Okay, this is the lastest code:
                    Code:
                    <?php
                    error_reporting(E_ALL);
                    ini_set('display_errors', true);
                    /* subject and email variables */
                    
                    		$emailSubject =  'Crazy PHP Scripting!';
                    		$WebMaster = 'webmaster@phptestfortazsite.xf-s.com';
                    		
                    		
                    /* Gathering Data Variables */
                    
                    		$emailField = $_POST['email'];	
                    		$nameField = $_POST['name'];	
                    		$commentsField = $_POST['comments'];
                    		
                    		
                    		$body = <<<EOD
                    <br><hr><br>
                    Email: $emailField <br>
                    Name: $nameField <br>
                    Comments: $commentsField <br>
                    EOD; 
                    
                    	$headers = "From: $emailField\r\n";
                    	$headers = "Content-type: text/html\r\n";	
                    	$success = mail($WebMaster, $emailSubject, $body, $headers);
                    	
                    	  	
                    /* results rendered as html*/
                    
                    	$theResults = <<<EOD
                    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                    <html xmlns="http://www.w3.org/1999/xhtml">
                    <head>
                    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                    <title>Sucess</title>
                    <link href="site.css" rel="stylesheet" type="text/css" />
                    </head>
                    
                    <body>
                    <p>Congratulations! Your Message was sent!</p>
                    <p>click <a href="homepage.html">here</a> to return to the mainpage</p>
                    </body>
                    </html>	
                    EOD;
                    echo "$theResults";
                    
                    ?>
                    and this is the error message I'm getting. I'm still really confused by it all :s

                    Code:
                     
                    Notice: Undefined variable: headers in /home2/exoduses/public_html/phptest.php on line 25
                    
                    Notice: Undefined variable: headers in /home2/exoduses/public_html/phptest.php on line 27
                    
                    Notice: Undefined variable: success in /home2/exoduses/public_html/phptest.php on line 27
                    
                    Notice: Undefined variable: body in /home2/exoduses/public_html/phptest.php on line 27
                    
                    Notice: Undefined variable: headers in /home2/exoduses/public_html/phptest.php on line 32
                    
                    Notice: Undefined variable: theResults in /home2/exoduses/public_html/phptest.php on line 45
                    
                    Notice: Undefined variable: theResults in /home2/exoduses/public_html/phptest.php on line 47
                    Jay

                    Comment

                    Working...