Solved

PHP Error

Posted on 2007-11-27
8
226 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 11

Expert Comment

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

<?php } ?>
 
0
 
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

Industry Leaders: 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!

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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.

733 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