Parse error: syntax error, unexpected $end in /home/blloyd/public_html/consultation/consult.php on line 209

It seems that the problem is in this bit of code...

the code is written as this...
====================
<TEXTAREA
id="newcustom5"
name="newcustom5"
rows="18"
onchange="validateWords(this, 'inf_newcustom5', 250);"
>
<?php
echo $slcustom5;
?>
</TEXTAREA></TD></TR>
====================
then it is automatically chaned by the Preview, or when I go back into the editor, to this...

=========================
<TEXTAREA id=newcustom5
 name=newcustom5
 rows=18
 onchange="validateWords(this, 'inf_newcustom5', 250);">
&lt;!--npcomments&lt;?php
echo $slcustom5;
?&gt;npcomments--&gt;
</TEXTAREA></TD></TR>
=========================

there must be someting wrong with the original code??

The code is trying to say, display what data is there, or add new data, or edit what is there.  The data is free text limited to 250 words.

blloyddAsked:
Who is Participating?
 
Harisha M GConnect With a Mentor Commented:
I strongly recommend you to INDENT your code.

If you indent your code properly, debugging errors will be piece of cake..
hiteshgupta1, found out the error, so did I, and here is the indented version of your full code: (Looks like you have many more lines of code and left 4 closing tags at the end... (Notice the comment I have put there)

_____________________
<P><IMG height="10" src="/images/spacer.gif" width="2"></P>
<FORM name="sitelokmodify" onsubmit="return validateOnSubmit()" action="preview.php" method="post">
<SCRIPT language="" type="text/javascript">

// Only script specific to this form goes here.
// General-purpose routines are in a separate file.

function validateOnSubmit()
{
    var elem;
    var errs=0;
    // execute all element validations in reverse order, so focus gets
    // set to the first one in error.

      if (!validateWords(document.forms.sitelokmodify.newcustom5, 'inf_newcustom5', 250)) errs += 1;
            <?php
            if (!$custom3)
            {
                  echo "if (!validateButton(document.forms.sitelokmodify.newcustom3, 'inf_newcustom3')) errs += 1;\n";
            }
            if (!$custom2)
            {
                   echo "if (!validateDate(document.forms.sitelokmodify.newcustom2, 'inf_newcustom2')) errs += 1;\n";
            }
            ?>
      if (!validatePresent(document.forms.sitelokmodify.newcustom1, 'inf_newcustom1')) errs += 1;

      if (errs>1)  alert('There are fields which need correction before sending');
      if (errs==1) alert('There is a field which needs correction before sending');

    return (errs==0);
};
</SCRIPT>
<?php sitelokmodify("",""); ?>
      <TABLE cellSpacing=2 cellPadding=3 align=center border=0>
            <TBODY>
                  <TR>
                        <TD noWrap align=right width="25%">Name: </TD>
                <TD width="45%">
                              <INPUT id="newcustom1" maxLength="50" onchange="validatePresent(this, 'inf_newcustom1');" size="30" value="<?php echo $custom1; ?>" name="newcustom1">
                        </TD>
                <TD class="warn id=inf_newcustom1" width="30%">&nbsp;</TD>
                  </TR>
            <TR>
                        <TD noWrap align="right">Email: </TD>
                <TD><?php echo $slusername; ?></TD>
                <TD><A href="/consultation/update_email.php">Change email
                  address</A></TD>
                  </TR>
            <TR>
                <TD vAlign="top" noWrap align="right">Date of Birth: <BR>(DD/MM/YYYY)
                        </TD>
                <TD vAlign=top>
<?php
      if (!$custom2)
      {
            echo ("<input name=\"newcustom2\" type=\"text\" id=\"newcustom2\" onChange=\"validateDate(this, 'inf_newcustom2');\" size=\"10\" maxlength=\"10\">");
      }
      else
      {
            echo $custom2;
      }
?>                        </TD>
                        <TD class=warn id=inf_newcustom2>&nbsp;</TD>
                  </TR>
            <TR>
                        <TD vAlign=top noWrap align=right>Gender:</TD>
                        <TD>
<?php
      if (!$custom3)
      {
            echo ("<input type=\"radio\" name=\"newcustom3\" ");
            if (!(strcmp($slcustom3,'Male')))
            {
                  echo ("checked");
            }
            echo (" onClick=\"validateButton(this, 'inf_newcustom3');\" value= \"Male\">");
            echo ("Male<BR>");


            echo ("<input type=\"radio\" name=\"newcustom3\" ");
            if (!(strcmp($slcustom3,'Female')))
            {
                  echo ("checked");
            }
            echo (" onClick=\"validateButton(this, 'inf_newcustom3');\" value= \"Female\">");
            echo ("Female<BR>");
      }
?>
                        </TD>
                        <TD class="warn" id="inf_newcustom3">&nbsp;</TD>
                  </TR>
                  <TR>
                        <TD vAlign="top" noWrap align="right">Enrolment Date: </TD>
                <TD>
<?php
      $year=substr($created,0,2);
      $month=substr($created,2,2);
      $day=substr($created,4,2);
      $datecreated=$day."/".$month."/20".$year;
      echo $datecreated;
?>
                        </TD>
                <TD>&nbsp;</TD>
                  </TR>
            <TR>
                        <TD vAlign="top" noWrap align="right">Last Consultation: </TD>
                <TD>
<?php
      echo $custom4;
?></TD>
                <TD>&nbsp;</TD>
                  </TR>
            <TR>
                        <TD noWrap align="left" colSpan="2">Question (250 words): </TD>
                        <TD class="warn" id="inf_newcustom5">&nbsp;</TD>
                  </TR>
                  <TR>
                        <TD noWrap align="middle" colSpan="3">

                              <TEXTAREA id="newcustom5" name="newcustom5" rows="18" onchange="validateWords(this, 'inf_newcustom5', 250);">
<?php
      echo $slcustom5;
?>
                              </TEXTAREA>
                        </TD>
                  </TR>
             
                  <TR align=middle>
                        <TD colSpan=3><INPUT type="submit" value="Preview and Save" name="Submit"></TD></TR></TBODY></TABLE></FORM>
                              <TABLE cellSpacing="2" cellPadding="3" width="100%" border="0">
                                    <TBODY>
                                          <TR>
                                                <TD>&nbsp;</TD>
                                                <TD align=right>
                                                      <A href="<?php siteloklogout(); ?>">Exit Without Saving</A>
                                                </TD>
                                          </TR>
                                    </TBODY>
                              </TABLE>
                        </TD>
                  </TR>
            </TBODY>
      </TABLE>
<!-- SHOULD IT NOT HAVE A CLOSING FORM TAG ? -->
</TD>
</TR>
</TBODY>
</TABLE>
0
 
Harisha M GCommented:
Hi, are you using HTML Tidy ?

---
Harish
0
 
Harisha M GCommented:
blloydd, the causes for the unexpected $end are:

1) You missed a semicolon (Not necessarily on the stated line, may be anywhere in the whole page)
2) You missed a } (Not necessarily on the stated line, may be anywhere in the whole page)
3) You missed a " (Not necessarily on the stated line, may be anywhere in the whole page)

So, this is one of the worst errors to debug. If you can correct it, fine. Otherwise, post the code of the *full page*.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
b0lsc0ttIT ManagerCommented:
blloydd,

MGH is correct in what can cause that error.  It may help to find out what you are using as your editor program.  If the editor program is displaying the code as you showed in the second example then it does not seem that it is a real HTML editor program.  If it is changing the code then those changes may be causing the error.

If possible use a basic text editor, like Notepad in Windows, to write the script.  When you save the file make sure that it is not saved with a txt or other extension but with a php extension.  Put the file on your web server using FTP software or by uploading it.  If that file does not have a problem then you should avoid the editor you are using.

Let me know if you have any questions or need more information.


P.S. If you do post the code then don't post the "previewed" version.  It would be useless.

b0lsc0tt
0
 
blloyddAuthor Commented:
if there isa an error it should be in this section...

==============================
<P><IMG height="10" src="/images/spacer.gif" width="2"></P>
<FORM name="sitelokmodify" onsubmit="return validateOnSubmit()" action="preview.php" method="post">
<SCRIPT language="" type="text/javascript">

// Only script specific to this form goes here.
// General-purpose routines are in a separate file.

function validateOnSubmit() {
    var elem;
    var errs=0;
    // execute all element validations in reverse order, so focus gets
    // set to the first one in error.

if (!validateWords(document.forms.sitelokmodify.newcustom5, 'inf_newcustom5', 250)) errs += 1;
  <?php
  if (!$custom3)
    {
    echo "if (!validateButton(document.forms.sitelokmodify.newcustom3, 'inf_newcustom3')) errs += 1;\n";
    }
  ?>
  <?php
  if (!$custom2)
  {
     echo "if (!validateDate(document.forms.sitelokmodify.newcustom2, 'inf_newcustom2')) errs += 1;\n";
  }
  ?>
    if (!validatePresent(document.forms.sitelokmodify.newcustom1, 'inf_newcustom1')) errs += 1;

    if (errs>1)  alert('There are fields which need correction before sending');
    if (errs==1) alert('There is a field which needs correction before sending');

    return (errs==0);
  };
</SCRIPT>
<?php sitelokmodify("",""); ?>
            <TABLE cellSpacing=2 cellPadding=3 align=center border=0>
              <TBODY>
              <TR>
                <TD noWrap align=right width="25%">Name: </TD>
                <TD width="45%">
                <INPUT id="newcustom1" maxLength="50" onchange="validatePresent(this, 'inf_newcustom1');" size="30" value="<?php echo $custom1; ?>" name="newcustom1"></TD>
                <TD class="warn id=inf_newcustom1" width="30%">&nbsp;</TD></TR>
              <TR>
                <TD noWrap align="right">Email: </TD>
                <TD><?php echo $slusername; ?></TD>
                <TD><A href="/consultation/update_email.php">Change email
                  address</A></TD></TR>
              <TR>
                <TD vAlign="top" noWrap align="right">Date of Birth:
                  <BR>(DD/MM/YYYY) </TD>
                <TD vAlign=top>
<?php
  if (!$custom2) {
     echo ("<input name=\"newcustom2\" type=\"text\" id=\"newcustom2\" onChange=\"validateDate(this, 'inf_newcustom2');\" size=\"10\" maxlength=\"10\">");
  }
  else
  {
    echo $custom2;
  }
?> </TD>
              <TD class=warn id=inf_newcustom2>&nbsp;</TD></TR>
              <TR>
              <TD vAlign=top noWrap align=right>Gender:</TD>
              <TD>

<?php
  if (!$custom3)
  {
     echo ("<input type=\"radio\" name=\"newcustom3\" ");
     if (!(strcmp($slcustom3,'Male')))
    {
      echo ("checked");
    }
    echo (" onClick=\"validateButton(this, 'inf_newcustom3');\" value= \"Male\">");
echo ("Male<BR>");


     echo ("<input type=\"radio\" name=\"newcustom3\" ");
     if (!(strcmp($slcustom3,'Female')))
    {
      echo ("checked");
    }
    echo (" onClick=\"validateButton(this, 'inf_newcustom3');\" value= \"Female\">");
echo ("Female<BR>");
?>
</TD>
               

<TD class="warn" id="inf_newcustom3">&nbsp;</TD></TR>
              <TR>
                <TD vAlign="top" noWrap align="right">Enrolment Date: </TD>
                <TD>
<?php
$year=substr($created,0,2);
$month=substr($created,2,2);
$day=substr($created,4,2);
$datecreated=$day."/".$month."/20".$year;
echo $datecreated;
?>
</TD>
                <TD>&nbsp;</TD></TR>
              <TR>
                <TD vAlign="top" noWrap align="right">Last Consultation: </TD>
                <TD>
<?php
echo $custom4;
?></TD>
                <TD>&nbsp;</TD></TR>
              <TR>
                <TD noWrap align="left" colSpan="2">Question (250 words): </TD>
                <TD class="warn" id="inf_newcustom5">&nbsp;</TD></TR>
              <TR>
                <TD noWrap align="middle" colSpan="3">

<TEXTAREA
id="newcustom5"
name="newcustom5"
rows="18"
onchange="validateWords(this, 'inf_newcustom5', 250);"
>
<?php
echo $slcustom5;
?>
</TEXTAREA></TD></TR>
             
<TR align=middle>
<TD colSpan=3><INPUT type="submit" value="Preview and Save" name="Submit"></TD></TR></TBODY></TABLE></FORM>
            <TABLE cellSpacing="2" cellPadding="3" width="100%" border="0">
              <TBODY>
              <TR>
                <TD>&nbsp;</TD>
<TD align=right>
<A href="<?php siteloklogout(); ?>">Exit Without Saving</A>
</TD>

</TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
=====================
0
 
blloyddAuthor Commented:
tried the suggestion by b0lsc0tt.  Didn't change the error message.  MGH could be right, there is an uneven number of brackets {=9 }=8, but I'm not able to tell which should be there or not.  Full code is above
0
 
hiteshgupta1Connect With a Mentor Commented:
UR problem lies in following portion of the code

<?php
  if (!$custom3)
  {
     echo ("<input type=\"radio\" name=\"newcustom3\" ");
     if (!(strcmp($slcustom3,'Male')))
    {
      echo ("checked");
    }
    echo (" onClick=\"validateButton(this, 'inf_newcustom3');\" value= \"Male\">");
echo ("Male<BR>");


     echo ("<input type=\"radio\" name=\"newcustom3\" ");
     if (!(strcmp($slcustom3,'Female')))
    {
      echo ("checked");
    }
    echo (" onClick=\"validateButton(this, 'inf_newcustom3');\" value= \"Female\">");
echo ("Female<BR>");
?>


u need to add one "}" at the end of this portion
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.