Solved

PHP Error

Posted on 2007-11-27
8
215 Views
Last Modified: 2010-04-21
I am receiving the following error on the attached code:

Parse error: parse error, unexpected ';', expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /var/www/vhosts/greenbaumstaging.com/subdomains/directed/httpdocs/administrator/components/com_staff/admin.staff.html.php on line 93

I don't understand what's causing this. And I'm not sure if it will list line numbers, so line 93 is the ending curly brace for the "edit" function.
<?php

//staff Component//

/**

* Content code

* @package staff

* @ staff is Free Software

* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html

* @version 1.0

**/
 

// ensure this file is being included by a parent file

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
 

require_once($mosConfig_absolute_path."/administrator/components/com_staff/class.staff.php");
 

class HTML_staff {
 

function edit( $option, &$row ) {

?>

  <script language="javascript" type="text/javascript">

		function changeStaffImage() {

			if (document.adminForm.imageurl.value !='') {

				document.adminForm.imagelib.src='../images/staff/' + document.adminForm.imageurl.value;

			} else {

				document.adminForm.imagelib.src='images/blank.png';

			}

		}

		function submitbutton(pressbutton) {

			var form = document.adminForm;

			if (pressbutton == 'cancel') {

				submitform( pressbutton );

				return;

			}

			// do field validation

			if (form.name.value == "") {

				alert( "You must provide a staff name." );

			} else if (form.title.value == "") {

				alert( "You must provide a staff title." );

			} else if (!getSelectedValue('adminForm','imageurl')) {

				alert( "Please select an image." );

			} else if (form.bio.innerHTML == "") {

				alert( "You must provide a staff biography." );

			} else {

				submitform( pressbutton );

			}

		}

  </script>
 

<form action="index2.php" method="post" name="adminForm" id="adminForm" class="adminForm">

<table border="0" cellpadding="3" cellspacing="0">

 <tr valign="top">

  <td>Name: </td>

  <td><input type="text" size="50" maxsize="100" name="name" value="<?php echo $row->name; ?>" /></td>

 </tr>

 <tr valign="top">

  <td>Title: </td>

  <td><input type="text" size="50" maxsize="100" name="title" value="<?php echo $row->title; ?>" /></td>

 </tr>

 <tr valign="top">

  <td>Select Image: </td>

  <td><br>*To upload new images, use the "Upload" button located beside the "Save" button.</td>

 </tr>

 <tr valign="top">

  <td>Image Preview: </td>

  <td>

   <?php

	if (eregi("swf", $row->image)) {

    ?>

	<img src="images/blank.png" name="imagelib">

   <?php

	} elseif (eregi("gif|jpg|png", $row->image)) {

	?>

	<img src="../images/staff/<?php echo $row->image; ?>" name="imagelib" />

	<?php

	} else {

	?>

	<img src="images/blank.png" name="imagelib" />

	<?php

	}

	?>

   </td>

 </tr>

 <tr valign="top">

  <td>Biography: </td>

  <td><textarea rows="10" cols="40" name="bio"><?php echo $row->bio; ?></textarea><br>*Use the &lt;br&gt; tag to add line breaks.</td>

 </tr>

</table>
 

<input type="hidden" name="id" value="<?php echo $row->id; ?>" />

<input type="hidden" name="option" value="<?php echo $option; ?>" />

<input type="hidden" name="task" value="" />

</form>

<?php } ?>
 

<?php

function showStaff( $option, &$rows ) {

 ?>

  <script language="javascript" type="text/javascript">

  function submitbutton(pressbutton) {

    var form = document.adminForm;

    if (pressbutton == "cancel") {

      submitform( pressbutton );

      return;

    }

    submitform( pressbutton );

  }

  </script>

  <form action="index2.php" method="post" name="adminForm">

  <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">

   <tr>

    <th width="20"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($rows); ?>);" /></th>

    <th class="title" width="25%">Name</th>

    <th width="25%">Published</th>

   </tr>

  <?php

    $k = 0;

    for($i=0; $i < count( $rows ); $i++) {

    $row = $rows[$i];

   ?>

    <tr class="<?php echo "row$k"; ?>">

     <td><input type="checkbox" id="cb<?php echo $i;?>" name="id[]" value="<?php echo $row->id; ?>" onclick="isChecked(this.checked);" /></td>

     <td><a href="#edit" onclick="return listItemTask('cb<?php echo $i;?>','edit')"><?php echo $row->name; ?></a></td>

     <td align="center">

      <?php

       if ($row->published == "1") {

         echo "<img src=\"images/tick.png\" border=\"0\" />";

       } else {

         echo "<img src=\"images/publish_x.png\" border=\"0\" />";

       }

      ?>

     </td>

     <?php $k = 1 - $k; ?>

    </tr>

  <?php } ?>

  <input type="hidden" name="option" value="<?php echo $option; ?>" />

  <input type="hidden" name="task" value="" />

  <input type="hidden" name="boxchecked" value="0" />

  </form>

 <?php }

} ?>

Open in new window

0
Comment
Question by:brettfarris
8 Comments
 
LVL 21

Expert Comment

by:nizsmo
ID: 20356277
I think you had an extra un-needed bracket.
<?php

//staff Component//

/**

* Content code

* @package staff

* @ staff is Free Software

* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html

* @version 1.0

**/

 

// ensure this file is being included by a parent file

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

 

require_once($mosConfig_absolute_path."/administrator/components/com_staff/class.staff.php");

 

class HTML_staff {

 

function edit( $option, &$row ) {

?>

  <script language="javascript" type="text/javascript">

                function changeStaffImage() {

                        if (document.adminForm.imageurl.value !='') {

                                document.adminForm.imagelib.src='../images/staff/' + document.adminForm.imageurl.value;

                        } else {

                                document.adminForm.imagelib.src='images/blank.png';

                        }

                }

                function submitbutton(pressbutton) {

                        var form = document.adminForm;

                        if (pressbutton == 'cancel') {

                                submitform( pressbutton );

                                return;

                        }

                        // do field validation

                        if (form.name.value == "") {

                                alert( "You must provide a staff name." );

                        } else if (form.title.value == "") {

                                alert( "You must provide a staff title." );

                        } else if (!getSelectedValue('adminForm','imageurl')) {

                                alert( "Please select an image." );

                        } else if (form.bio.innerHTML == "") {

                                alert( "You must provide a staff biography." );

                        } else {

                                submitform( pressbutton );

                        }

                }

  </script>

 

<form action="index2.php" method="post" name="adminForm" id="adminForm" class="adminForm">

<table border="0" cellpadding="3" cellspacing="0">

 <tr valign="top">

  <td>Name: </td>

  <td><input type="text" size="50" maxsize="100" name="name" value="<?php echo $row->name; ?>" /></td>

 </tr>

 <tr valign="top">

  <td>Title: </td>

  <td><input type="text" size="50" maxsize="100" name="title" value="<?php echo $row->title; ?>" /></td>

 </tr>

 <tr valign="top">

  <td>Select Image: </td>

  <td><br>*To upload new images, use the "Upload" button located beside the "Save" button.</td>

 </tr>

 <tr valign="top">

  <td>Image Preview: </td>

  <td>

   <?php

        if (eregi("swf", $row->image)) {

    ?>

        <img src="images/blank.png" name="imagelib">

   <?php

        } elseif (eregi("gif|jpg|png", $row->image)) {

        ?>

        <img src="../images/staff/<?php echo $row->image; ?>" name="imagelib" />

        <?php

        } else {

        ?>

        <img src="images/blank.png" name="imagelib" />

        <?php

        }

        ?>

   </td>

 </tr>

 <tr valign="top">

  <td>Biography: </td>

  <td><textarea rows="10" cols="40" name="bio"><?php echo $row->bio; ?></textarea><br>*Use the &lt;br&gt; tag to add line breaks.</td>

 </tr>

</table>

 

<input type="hidden" name="id" value="<?php echo $row->id; ?>" />

<input type="hidden" name="option" value="<?php echo $option; ?>" />

<input type="hidden" name="task" value="" />

</form>
 

 

<?php

function showStaff( $option, &$rows ) {

 ?>

  <script language="javascript" type="text/javascript">

  function submitbutton(pressbutton) {

    var form = document.adminForm;

    if (pressbutton == "cancel") {

      submitform( pressbutton );

      return;

    }

    submitform( pressbutton );

  }

  </script>

  <form action="index2.php" method="post" name="adminForm">

  <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">

   <tr>

    <th width="20"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($rows); ?>);" /></th>

    <th class="title" width="25%">Name</th>

    <th width="25%">Published</th>

   </tr>

  <?php

    $k = 0;

    for($i=0; $i < count( $rows ); $i++) {

    $row = $rows[$i];

   ?>

    <tr class="<?php echo "row$k"; ?>">

     <td><input type="checkbox" id="cb<?php echo $i;?>" name="id[]" value="<?php echo $row->id; ?>" onclick="isChecked(this.checked);" /></td>

     <td><a href="#edit" onclick="return listItemTask('cb<?php echo $i;?>','edit')"><?php echo $row->name; ?></a></td>

     <td align="center">

      <?php

       if ($row->published == "1") {

         echo "<img src=\"images/tick.png\" border=\"0\" />";

       } else {

         echo "<img src=\"images/publish_x.png\" border=\"0\" />";

       }

      ?>

     </td>

     <?php $k = 1 - $k; ?>

    </tr>

  <?php } ?>

  <input type="hidden" name="option" value="<?php echo $option; ?>" />

  <input type="hidden" name="task" value="" />

  <input type="hidden" name="boxchecked" value="0" />

  </form>

 <?php }

} ?>

Open in new window

0
 
LVL 49

Expert Comment

by:Roonaan
ID: 20356278
Hello brettfarris,

Shouldn't it be:
<tr><td class="lineNumber">133:</td><td><?php } ?></td></tr>
instead of
<tr><td class="lineNumber">133:</td><td>} ?></td></tr>

Regards,

Roonaan
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20356287
sorry ignore my previous comment, issue wasn't fixed..
0
 
LVL 11

Expert Comment

by:elfe69
ID: 20356288
Remove the following line before function showStaff:

<?php } ?>
 
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 21

Accepted Solution

by:
nizsmo earned 500 total points
ID: 20356305
@elfe69:

I think that produces another error at the bottom with the brackets.

I think this should fix it in terms of syntax errors.
<?php

//staff Component//

/**

* Content code

* @package staff

* @ staff is Free Software

* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html

* @version 1.0

**/

 

// ensure this file is being included by a parent file

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

 

require_once($mosConfig_absolute_path."/administrator/components/com_staff/class.staff.php");

 

class HTML_staff {

 

function edit( $option, &$row ) {

?>

  <script language="javascript" type="text/javascript">

		function changeStaffImage() {

			if (document.adminForm.imageurl.value !='') {

				document.adminForm.imagelib.src='../images/staff/' + document.adminForm.imageurl.value;

			} else {

				document.adminForm.imagelib.src='images/blank.png';

			}

		}

		function submitbutton(pressbutton) {

			var form = document.adminForm;

			if (pressbutton == 'cancel') {

				submitform( pressbutton );

				return;

			}

			// do field validation

			if (form.name.value == "") {

				alert( "You must provide a staff name." );

			} else if (form.title.value == "") {

				alert( "You must provide a staff title." );

			} else if (!getSelectedValue('adminForm','imageurl')) {

				alert( "Please select an image." );

			} else if (form.bio.innerHTML == "") {

				alert( "You must provide a staff biography." );

			} else {

				submitform( pressbutton );

			}

		}

  </script>

 

<form action="index2.php" method="post" name="adminForm" id="adminForm" class="adminForm">

<table border="0" cellpadding="3" cellspacing="0">

 <tr valign="top">

  <td>Name: </td>

  <td><input type="text" size="50" maxsize="100" name="name" value="<?php echo $row->name; ?>" /></td>

 </tr>

 <tr valign="top">

  <td>Title: </td>

  <td><input type="text" size="50" maxsize="100" name="title" value="<?php echo $row->title; ?>" /></td>

 </tr>

 <tr valign="top">

  <td>Select Image: </td>

  <td><br>*To upload new images, use the "Upload" button located beside the "Save" button.</td>

 </tr>

 <tr valign="top">

  <td>Image Preview: </td>

  <td>

   <?php

	if (eregi("swf", $row->image)) {

    ?>

	<img src="images/blank.png" name="imagelib">

   <?php

	} elseif (eregi("gif|jpg|png", $row->image)) {

	?>

	<img src="../images/staff/<?php echo $row->image; ?>" name="imagelib" />

	<?php

	} else {

	?>

	<img src="images/blank.png" name="imagelib" />

	<?php

	}

	?>

   </td>

 </tr>

 <tr valign="top">

  <td>Biography: </td>

  <td><textarea rows="10" cols="40" name="bio"><?php echo $row->bio; ?></textarea><br>*Use the &lt;br&gt; tag to add line breaks.</td>

 </tr>

</table>

 

<input type="hidden" name="id" value="<?php echo $row->id; ?>" />

<input type="hidden" name="option" value="<?php echo $option; ?>" />

<input type="hidden" name="task" value="" />

</form>

<?php }
 
 

function showStaff( $option, &$rows ) {

 ?>

  <script language="javascript" type="text/javascript">

  function submitbutton(pressbutton) {

    var form = document.adminForm;

    if (pressbutton == "cancel") {

      submitform( pressbutton );

      return;

    }

    submitform( pressbutton );

  }

  </script>

  <form action="index2.php" method="post" name="adminForm">

  <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">

   <tr>

    <th width="20"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($rows); ?>);" /></th>

    <th class="title" width="25%">Name</th>

    <th width="25%">Published</th>

   </tr>

  <?php

    $k = 0;

    for($i=0; $i < count( $rows ); $i++) {

    $row = $rows[$i];

   ?>

    <tr class="<?php echo "row$k"; ?>">

     <td><input type="checkbox" id="cb<?php echo $i;?>" name="id[]" value="<?php echo $row->id; ?>" onclick="isChecked(this.checked);" /></td>

     <td><a href="#edit" onclick="return listItemTask('cb<?php echo $i;?>','edit')"><?php echo $row->name; ?></a></td>

     <td align="center">

      <?php

       if ($row->published == "1") {

         echo "<img src=\"images/tick.png\" border=\"0\" />";

       } else {

         echo "<img src=\"images/publish_x.png\" border=\"0\" />";

       }

      ?>

     </td>

     <?php $k = 1 - $k; ?>

    </tr>

  <?php } ?>

  <input type="hidden" name="option" value="<?php echo $option; ?>" />

  <input type="hidden" name="task" value="" />

  <input type="hidden" name="boxchecked" value="0" />

  </form>

 <?php }

} ?>

Open in new window

0
 
LVL 11

Expert Comment

by:elfe69
ID: 20356333
You are right nizsmo: the parser does not like the following syntax:

<?php } ?>
 
<?php
function showStaff( $option, &$rows ) {

which should be replaced by:

<?php }
function showStaff( $option, &$rows ) {

0
 

Author Closing Comment

by:brettfarris
ID: 31411154
Excellent, thanks!
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20379931
Glad to help :)
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

759 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

21 Experts available now in Live!

Get 1:1 Help Now