Solved

PHP Error

Posted on 2007-11-27
8
223 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP installation issues 11 59
is this a cms? 8 57
How can I implement a "Select All" with this configuration...? 6 38
How would I do this...? 2 27
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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 dynamically set the form action using jQuery.

816 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