Jump to content

[SOLVED] Parse error


eaglelegend

Recommended Posts

Hi, sorry guys, I have come accross an error on my site and I am unsure qhats causing it, this is the error

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in contact.php on line 44

 

This is everything from line 1 to 50;

<?php

session_name("fancyform");
session_start();


$_SESSION['n1'] = rand(1,20);
$_SESSION['n2'] = rand(1,20);
$_SESSION['expect'] = $_SESSION['n1']+$_SESSION['n2'];


$str='';
if($_SESSION['errStr'])
{
$str='<div class="error">'.$_SESSION['errStr'].'</div>';
unset($_SESSION['errStr']);
}

$success='';
if($_SESSION['sent'])
{
$success='<h1>Thank you!</h1>';

$css='<style type="text/css">#contact-form{display:none;}</style>';

unset($_SESSION['sent']);
}


$page = 'contact';

$content=<<<EOF

<div id="main-container">

<div id="form-container">
    <h1>Contact Form</h1>
    <h2>Why not drop us a line and we will get back to you!</h2>
    
    <form id="contact-form" name="contact-form" method="post" action="submit.php">
      <table width="100%" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td width="15%"><label for="name">Name</label></td>
          <td width="70%"><input type="text" class="validate[required,custom[onlyLetter]]" name="name" id="name" value="<?=$_SESSION['post']['name']?>" /></td>
          <td width="15%" id="errOffset"> </td>
        </tr>
        <tr>
          <td><label for="email">Email</label></td>
          <td><input type="text" class="validate[required,custom[email]]" name="email" id="email" value="<?=$_SESSION['post']['email']?>" /></td>
          <td> </td>

Link to comment
Share on other sites

Try this:

<?php

session_name("fancyform");
session_start();


$_SESSION['n1'] = rand(1,20);
$_SESSION['n2'] = rand(1,20);
$_SESSION['expect'] = $_SESSION['n1']+$_SESSION['n2'];


$str='';
if($_SESSION['errStr'])
{
   $str='<div class="error">'.$_SESSION['errStr'].'</div>';
   unset($_SESSION['errStr']);
}

$success='';
if($_SESSION['sent'])
{
   $success='<h1>Thank you!</h1>';
   
   $css='<style type="text/css">#contact-form{display:none;}</style>';
   
   unset($_SESSION['sent']);
}


$page = 'contact';

$content=<<<EOF

<div id="main-container">

   <div id="form-container">
    <h1>Contact Form</h1>
    <h2>Why not drop us a line and we will get back to you!</h2>
    
    <form id="contact-form" name="contact-form" method="post" action="submit.php">
      <table width="100%" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td width="15%"><label for="name">Name</label></td>
          <td width="70%"><input type="text" class="validate[required,custom[onlyLetter]]" name="name" id="name" value="{$_SESSION['post']['name']}" /></td>
          <td width="15%" id="errOffset"> </td>
        </tr>
        <tr>
          <td><label for="email">Email</label></td>
          <td><input type="text" class="validate[required,custom[email]]" name="email" id="email" value="{$_SESSION['post']['email']}" /></td>
          <td> </td>
EOF;
// There must be a hard-return afer EOF; or you will receive an end-of-file error.

Link to comment
Share on other sites

Same error, I tried changing the other one you mentioned but same error, so heres the full code, I dont believe it is over 300 lines though.

 

<?php

session_name("fancyform");
session_start();


$_SESSION['n1'] = rand(1,20);
$_SESSION['n2'] = rand(1,20);
$_SESSION['expect'] = $_SESSION['n1']+$_SESSION['n2'];


$str='';
if($_SESSION['errStr'])
{
$str='<div class="error">'.$_SESSION['errStr'].'</div>';
unset($_SESSION['errStr']);
}

$success='';
if($_SESSION['sent'])
{
$success='<h1>Thank you!</h1>';

$css='<style type="text/css">#contact-form{display:none;}</style>';

unset($_SESSION['sent']);
}


$page = 'contact';

$content=<<<EOF

<div id="main-container">

<div id="form-container">
    <h1>Contact Form</h1>
    <h2>Why not drop us a line and we will get back to you!</h2>
    
    <form id="contact-form" name="contact-form" method="post" action="submit.php">
      <table width="100%" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td width="15%"><label for="name">Name</label></td>
          <td width="70%"><input type="text" class="validate[required,custom[onlyLetter]]" name="name" id="name" value="<?php echo $_SESSION['post']['name']; ?>" /></td>
          <td width="15%" id="errOffset"> </td>
        </tr>
        <tr>
          <td><label for="email">Email</label></td>
          <td><input type="text" class="validate[required,custom[email]]" name="email" id="email" value="<?=$_SESSION['post']['email']?>" /></td>
          <td> </td>
        </tr>
        <tr>
          <td><label for="subject">Subject</label></td>
          <td><select name="subject" id="subject">
            <option value="" selected="selected"> - Choose -</option>
            <option value="Question">Question</option>
            <option value="Business proposal">Business proposal</option>
            <option value="Advertisement">Advertising</option>
            <option value="Complaint">Complaint</option>
          </select>          </td>
          <td> </td>
        </tr>
        <tr>
          <td valign="top"><label for="message">Message</label></td>
          <td><textarea name="message" id="message" class="validate[required]" cols="35" rows="5"><?=$_SESSION['post']['message']?></textarea></td>
          <td valign="top"> </td>
        </tr>
        <tr>
          <td><label for="captcha"><?=$_SESSION['n1']?> + <?=$_SESSION['n2']?> =</label></td>
          <td><input type="text" class="validate[required,custom[onlyNumber]]" name="captcha" id="captcha" /></td>
          <td valign="top"> </td>
        </tr>
        <tr>
          <td valign="top"> </td>
          <td colspan="2"><input type="submit" name="button" id="button" value="Submit" />
          <input type="reset" name="button2" id="button2" value="Reset" />
          
          <?=$str?>          <img id="loading" src="/img/ajax-load.gif" width="16" height="16" alt="loading" /></td>
        </tr>
      </table>
      </form>
      <?=$success?>
    </div>
</div>
			<br />
			<br />

EOF;

include_once ( 'template.php' );

?> 

Link to comment
Share on other sites

You copied and pasted my sample code?  Im a bit confused as to what you've done, but you did not copy/paste what I posted.  Take a look specifically at the parts where you close PHP in the middle of your HTML:

 

<?php echo $_SESSION['post']['name']; ?>

<?=$_SESSION['post']['email']?>

<?=$_SESSION['post']['message']?>

<?=$_SESSION['n1']?>

<?=$_SESSION['n2']?>

<?=$success?>

 

(and possibly more; I only skimmed through the last code you posted.)

 

You can not close PHP in the middle of your heredoc syntax as you are doing.  See my code from the previous post for the correct way.

Link to comment
Share on other sites

try

 


$name = $_SESSION['post']['name'];

$content=<<<EOF

<div id="main-container">

   <div id="form-container">
    <h1>Contact Form</h1>
    <h2>Why not drop us a line and we will get back to you!</h2>
    
    <form id="contact-form" name="contact-form" method="post" action="submit.php">
      <table width="100%" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td width="15%"><label for="name">Name</label></td>
          <td width="70%"><input type="text" class="validate[required,custom[onlyLetter]]" name="name" id="name" value="$name" /></td>

OR

<td width="70%"><input type="text" class="validate[required,custom[onlyLetter]]" name="name" id="name" value="{$name}" /></td>

          <td width="15%" id="errOffset"> </td>
        </tr>
        <tr>
          <td><label for="email">Email</label></td>
          <td><input type="text" class="validate[required,custom[email]]" name="email" id="email" value="<?=$_SESSION['post']['email']?>" /></td>
          <td> </td>

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.