Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2006-06-26
7
Medium Priority
?
412 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
ID: 16988704
Hi, are you using HTML Tidy ?

---
Harish
0
 
LVL 37

Expert Comment

by:Harisha M G
ID: 16988717
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
ID: 16988827
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:blloydd
ID: 16988899
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
ID: 16989020
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 400 total points
ID: 16990833
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 1600 total points
ID: 16995067
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

916 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