Solved

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

Posted on 2006-06-26
7
398 Views
Last Modified: 2008-02-01
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.

0
Comment
Question by:blloydd
7 Comments
 
LVL 37

Expert Comment

by:Harisha M G
Comment Utility
Hi, are you using HTML Tidy ?

---
Harish
0
 
LVL 37

Expert Comment

by:Harisha M G
Comment Utility
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
 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:blloydd
Comment Utility
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
 

Author Comment

by:blloydd
Comment Utility
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
 
LVL 8

Assisted Solution

by:hiteshgupta1
hiteshgupta1 earned 100 total points
Comment Utility
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
 
LVL 37

Accepted Solution

by:
Harisha M G earned 400 total points
Comment Utility
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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now