unexpected T_ELSE

Discussion in 'PHP' started by meroving, Nov 4, 2008.

  1. #1
    still a new coder where did I go wrong here.

    Parse error: syntax error, unexpected T_ENDIF in C:\wamp\www\syn_cms\demo_items.php on line 210

    
    
    <body>
    <?php
    // All include files.
    include('config.php');
    include('mysqlcnx.php');
    include('dbcnx.php');
    include('english.php');
    ?>
    
    <?php if (isset($_GET['change_location'])): //If user wants to change demo location. ?>
    <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
    <label>Change Pod Manager: 
    <select name="di_pod">
    	<?php
    	$result = mysql_query('SELECT demo_pod_manager FROM syn_demo_pod');
    	while ($row = mysql_fetch_array($result)) {
    	$di_pod = $row['demo_pod_manager'];
    	echo '<option>' . $di_pod . '';
    	}
    	?>	
    </select>
    <br />
    <br />
    <label>Change Sales Rep: 
    <select name="di_sales">
    	<?php
    	$result = mysql_query('SELECT demo_rep_sales FROM syn_demo_rep');
    	while ($row = mysql_fetch_array($result)) {
    	$di_rep = $row['demo_rep_sales'];
    	echo '<option>' . $di_rep . '';
    	}
    	?>	
    </select>
    </label>
    <br /><br />
    <label>New Location: <input name="di_location" type="text" /></label>
    <br /><br />
    <label>Entry Date: <input name="di_entry" type="text" /></label>
    <br /><br />
    <label>Exit Date: <input name="di_exit" type="text" /></label>
    <br /><br />
    <label>Comment:
    <textarea name="di_comment" rows="10" cols="40"></textarea>
    </label><br/>
    <input name="di_id" type="hidden" value="<?php echo $_GET['id']; ?>" />
    <input type="submit" value="Change Location"/>
    </form>
    
    <?php else: //Else display default page display ?>
    
    <?php
    // If a new demo location has been added, add it to the database.
    if (isset($_POST['di_pod'])) {
    	$di_id = $_POST['di_id'];
    	$di_pod = $_POST['di_pod'];
    	$di_sales = $_POST['di_sales'];
    	$di_location = $_POST['di_location'];
    	$di_entry = $_POST['di_entry'];
    	$di_exit = $_POST['di_exit'];
    	$di_comment = $_POST['di_comment'];
    	
    		$sql_history = @mysql_query("INSERT INTO syn_demo_item_history SET
    						demo_item_history_ass = '$di_id',
    						demo_item_history_pod = '$di_pod',
    						demo_item_history_rep = '$di_sales',
    						demo_item_history_location = '$di_location',
    						demo_item_history_entry_date = '$di_entry',
    						demo_item_history_exit_date = '$di_exit',
    						demo_item_history_comment = '$di_comment',
    						fresh_entry = '1'");	
    		$sql_current = @mysql_query("UPDATE syn_demo_item SET
    						demo_item_last_pod = (SELECT demo_item_history_pod FROM syn_demo_item_history WHERE fresh_entry = 1),
    						demo_item_last_rep = (SELECT demo_item_history_rep FROM syn_demo_item_history WHERE fresh_entry = 1),
    						demo_item_last_location = (SELECT demo_item_history_location FROM syn_demo_item_history WHERE fresh_entry = 1),
    						demo_item_entry_date = (SELECT demo_item_history_entry_date FROM syn_demo_item_history WHERE fresh_entry = 1),
    						demo_item_exit_date = (SELECT demo_item_history_exit_date FROM syn_demo_item_history WHERE fresh_entry = 1),
    						demo_item_comment = (SELECT demo_item_history_comment FROM syn_demo_item_history WHERE fresh_entry = 1)
    						WHERE demo_item_id = '$di_id'");
    		$sql_fe_reset = @mysql_query("UPDATE syn_demo_item_history SET
    						fresh_entry = '0'");
    		if ($sql_history and $sql_current and $sql_fe_reset) {
    			echo'<p> Your demo item location has been changed.'  . mysql_error() . ' </p>';
    			} else {
    			echo '<p> There was an error changing your demo item location:' . mysql_error() . '</p>';
    			}
    		}
    ?>
    
    <?php
    $pod_managers = mysql_query('SELECT demo_pod_id, demo_pod_manager FROM syn_demo_pod');
    $sales_reps = mysql_query('SELECT demo_rep_id, demo_rep_sales FROM syn_demo_rep');
    ?>
    
    <!-- Menu/Search Form -->
    <form action ="<?php echo $_SERVER['PHP_SELF'];?><? echo '&search=1';?>" method="post">
    <table width="75%" border="0">
      <tr>
        <td><select name="pod_manager"><option selected value="">Select a Pod Manager</option>
    	<?php
    while ($pod_manager = mysql_fetch_array($pod_managers)) {
    	$pm_id = $pod_manager['demo_pod_id'];
    	$pm_name = htmlspecialchars($pod_manager['demo_pod_manager']);
    	echo "<option value='$pm_id'>$pm_name</option>";}
    	?></select>
    	</td>
        <td><select name="sales_rep"><option selected value="">Select a Sales Rep</option>
    	<?php
    while ($sales_rep = mysql_fetch_array($sales_reps)) {
    	$sr_id = $sales_rep['demo_rep_id'];
    	$sr_name = htmlspecialchars($sales_rep['demo_rep_sales']);
    	echo "<option value='$sr_id'>$sr_name</option>";}
    	?></select></td>
        <td><input type ="text" value="Search" name="searchlot" /></td>
        <td><input type ="text" value="Search" name="searchlocation" /></td>
        <td><input type="submit" value ="Search"  /></td>
      </tr>
    </table>
    </form>
    View Demo Items:
    <!-- Query Table of all demo items -->
    <?php
    
    $select = 'SELECT demo_item_id, demo_item_lot, demo_pod_id, demo_pod_manager, demo_item_last_pod, demo_rep_id, demo_rep_sales, demo_item_last_rep, demo_item_last_location, demo_item_entry_date, demo_item_exit_date FROM syn_demo_item, syn_demo_pod, syn_demo_rep WHERE demo_item_last_pod = demo_pod_id AND demo_item_last_rep = demo_rep_id';
    $from = ' FROM syn_demo_item, syn_demo_pod, syn_demo_rep';
    $where = ' WHERE 1=1 AND demo_item_last_pod = demo_pod_id AND demo_item_last_rep = demo_rep_id';
    
    $pm_id = $_POST['pod_manager'];
    	if ($pm_id != '') { //A Pod Manager has been selcted
    		$where .= " AND demo_pod_id = '$pm_id'";
    		
    $sr_id = $_POST['sales_rep'];
    	if ($pm_id != '') { //A Sales Rep has been selcted
    		$where .= " AND demo_rep_id = '$sr_id'";
    		
    $searchlot = $_POST['searchlot'];
    	if ($searchtext != '') { //A search string has been entered
    		$where .= " AND demo_item_lot = '$searchlot'";
    		
    $searchlocation = $_POST['searchlocation'];
    	if ($searchtext != '') { //A search string has been entered
    		$where .= " AND demo_item_location = '$searchlocation'";
    		?>
    
    
    
    <?php
    if (isset($_GET['search'])) {
    	$result = @mysql_query($select and $from and $where)
    	?>
    	<table width="75%" border="0">	
    	<?php
    	while ($row = mysql_fetch_array($result)) {
    	$di_id = $row['demo_item_id'];
    	$di_lot = $row['demo_item_lot'];
    	$di_pod = $row['demo_pod_manager'];
    	$di_rep = $row['demo_rep_sales'];
    	$di_location = $row['demo_item_last_location'];
    	$di_entry = $row['demo_item_entry_date'];
    	$di_exit = $row['demo_item_exit_date'];	
    	echo '
    	<td>' . $di_id . '</td>
    	<td>' . $di_lot . '</td>
    	<td>' . $di_pod . '</td>
    	<td>' . $di_rep . '</td>
    	<td>' . $di_location . '</td>
    	<td>' . $di_entry . '</td>
    	<td>' . $di_exit . '</td>
    	<td><a href ="' . $_SERVER['PHP_SELF'] . '?change_location=1&id=' . $di_id . '">' . $lang_change_location .'</a></tr>';
    	}
    	
    if (!isset($_GET['search'])) {
    $result = @mysql_query('SELECT demo_item_id, demo_item_lot, demo_pod_id, demo_pod_manager, demo_item_last_pod, demo_rep_id, demo_rep_sales, demo_item_last_rep, demo_item_last_location, demo_item_entry_date, demo_item_exit_date FROM syn_demo_item, syn_demo_pod, syn_demo_rep WHERE demo_item_last_pod = demo_pod_id AND demo_item_last_rep = demo_rep_id');
    	if (!$result) {
    	exit ('<p> Error performing query:' . mysql_error() . '</p>');
    	}
    	
    	?>
    	<table width="75%" border="0">
    	
    	<?php
    	while ($row = mysql_fetch_array($result)) {
    	$di_id = $row['demo_item_id'];
    	$di_lot = $row['demo_item_lot'];
    	$di_pod = $row['demo_pod_manager'];
    	$di_rep = $row['demo_rep_sales'];
    	$di_location = $row['demo_item_last_location'];
    	$di_entry = $row['demo_item_entry_date'];
    	$di_exit = $row['demo_item_exit_date'];	
    	echo '
    	<td>' . $di_id . '</td>
    	<td>' . $di_lot . '</td>
    	<td>' . $di_pod . '</td>
    	<td>' . $di_rep . '</td>
    	<td>' . $di_location . '</td>
    	<td>' . $di_entry . '</td>
    	<td>' . $di_exit . '</td>
    	<td><a href ="' . $_SERVER['PHP_SELF'] . '?change_location=1&id=' . $di_id . '">' . $lang_change_location .'</a></tr>';
    	}
    	?>
    
    
    
    </table>
    <?php endif; ?>
    </body>
    
    
    Code (markup):

     
    meroving, Nov 4, 2008 IP
  2. keyaa

    keyaa Peon

    Messages:
    137
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #2
    # of "{"-characters in your code: 16
    # of "}"-characters in your code: 10

    Fix your conditions. Don't come back until the amount of "{"'s and "}"'s in your code are equal :p
     
    keyaa, Nov 4, 2008 IP