Need help finding this syntax error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • David Morris
    New Member
    • Nov 2010
    • 4

    Need help finding this syntax error

    I keep getting this syntax error in one of my webpages and I have looked through it and I can't find it. Its not my includes because they work fine on my other pages. Please Help!

    Parse error: syntax error, unexpected $end in /home/david/public_html/post/realestate/commercial/edit_ad.php on line 537

    Code:
    <?php # edit_ad6002.php
    
    // Include the configuration file for error management and such.
    require_once('/home/david/includes/config.inc.php');
    
    require_once('/home/david/includes/mysql_connect.php');
    
    $sc = 6002;
    $no_redirect = 'true';
    $title = "Raptorads.com - Post Ad - Edit Ad";
    
    if (isset($_SESSION['user_id'])){
       if (isset($_GET['a'])) {
          $a = mysqli_real_escape_string($dbc, $_GET['a']);
    	  
          $query = "SELECT s FROM re WHERE ad_id=$a AND user_id=" . $_SESSION['user_id'];
    	  $result = mysqli_query ($dbc, $query);
          if (mysqli_num_rows($result) != 0){
    	     $row = mysqli_fetch_array ($result, MYSQL_NUM);
    		 
    		 if ($row[0] == 1){
    		    // Do nothing
    			
    			$rdir = 0;
    			$furl = "edit_ad.php?a=$a";
    		 } elseif ($row[0] == 2){
    		    if (isset($_GET['t']) && isset($_GET['k'])){
    			   $t = $_GET['t'];
    			   $k = $_GET['k'];
    			   $rdir = 1;
    			   $furl = "edit_ad.php?a=$a&t=$t&k=$k";
    			} else {
    			   require_once('/home/david/includes/header3.htm');
    			   require_once('/home/david/includes/session.inc.php');
    			   echo '<div id="middle">' . "\n";
    			   echo ' <div class="errors">' . "\n";
    			   echo '  <h2>Error!</h2>' . "\n";
    			   echo "  <p>Invalid or expired URL.</p>\n";
    			   echo ' </div>' . "\n";
    			   echo "</div><!-- End of Middle div-->\n";
    			   require_once('/home/david/includes/footer2.htm');
    			   exit();
    			}
    		 } else {
    		    require_once('/home/david/includes/header3.htm');
    			require_once('/home/david/includes/session.inc.php');
    			echo '<div id="middle">' . "\n";
    			echo ' <div class="errors">' . "\n";
    			echo '  <h2>Error!</h2>' . "\n";
    			echo "  <p>Invalid or expired URL.</p>\n";
    			echo ' </div>' . "\n";
    			echo "</div><!-- End of Middle div-->\n";
    			require_once('/home/david/includes/footer2.htm');
    			exit();
    		 }
          } else {
    	     require_once('/home/david/includes/header3.htm');
    		 require_once('/home/david/includes/session.inc.php');
    		 echo '<div id="middle">' . "\n";
    		 echo ' <div class="errors">' . "\n";
    		 echo '  <h2>Error!</h2>' . "\n";
    		 echo "  <p>Invalid or expired URL.</p>\n";
    		 echo ' </div>' . "\n";
    		 echo "</div><!-- End of Middle div-->\n";
    		 require_once('/home/david/includes/footer2.htm');
    		 exit();
    	  }
       } else {
          require_once('/home/david/includes/header3.htm');
          require_once('/home/david/includes/session.inc.php');
          echo '<div id="middle">' . "\n";
          echo ' <div class="errors">' . "\n";
          echo '  <h2>Error!</h2>' . "\n";
          echo "  <p>Invalid or expired URL.</p>\n";
          echo ' </div>' . "\n";
          echo "</div><!-- End of Middle div-->\n";
          require_once('/home/david/includes/footer2.htm');
          exit();
       }
    } else {
       require_once('/home/david/includes/header3.htm');
       require_once('/home/david/includes/session.inc.php');
       echo '<div id="middle">' . "\n";
       echo '<div class="login">' . "\n";
       echo '<form action="http://account.raptorads.com/login.php" method="post">' . "\n";
       echo '<h2>You must be logged in to view this page.</h2>' . "\n";
       echo '<label>User ID</label><br /><input type="text" name="user_name" size="20" maxlength="20" value="" /><br />' . "\n";
       echo '<label>Password</label><br /><input type="password" name="pass" size="21" maxlength="20" /><br />' . "\n";
       if (isset($ecurl)) {
          echo '<input type="hidden" name="ecurl" value="' . $ecurl . '" />' . "\n";
       }
       echo '<input type="hidden" name="submitted" value="TRUE" />' . "\n";
       echo '<input type="submit" name="submit" value="Login" /><br />' . "\n";
       echo '<p>I forgot my <a href="http://account.raptorads.com/forgot_user.php">User ID</a> or <a href="http://account.raptorads.com/forgot_password.php">Password</a></p>' . "\n";
       echo "</form>\n</div>\n";
       echo "</div><!-- End of Middle div-->\n";
       require_once('/home/david/includes/footer2.htm');
       exit();
    }
    
    $query = "SELECT title, description, price, pn FROM re WHERE ad_id=$a AND subcat=$sc AND user_id=" . $_SESSION['user_id'];
    $result1 = mysqli_query ($dbc, $query);
    $row1 = mysqli_fetch_array ($result1, MYSQL_NUM);
    
    $pn = array(substr($row1[3], 0, 3), substr($row1[3], 3, 3), substr($row1[3], 6, 4));
    
    if (substr($row1[2], 0, 1) == '$'){
       $c = strlen($row1[2]) - 4;
       $np = substr($row1[2], 1, $c);
    } else {
       $np = $row1[2];
    }
    
    if (mysqli_num_rows($result1) == 0) {
       require_once('/home/david/includes/header3.htm');
       require_once('/home/david/includes/session.inc.php');
       echo '<div id="middle">' . "\n";
       echo ' <div class="errors">' . "\n";
       echo '  <h2>Error!</h2>' . "\n";
       echo "  <p>Invalid or expired URL.</p>\n";
       echo ' </div>' . "\n";
       echo "</div><!-- End of Middle div-->\n";
       require_once('/home/david/includes/footer2.htm');
       exit();
    }
    
    $query = "SELECT `cat`, `fsb`, `type`, `sqft`, `year`, `mls`, `street`, `city`, `state`, `zip` FROM `$sc` WHERE ad_id=$a";
    $result2 = mysqli_query ($dbc, $query);
    $row2 = mysqli_fetch_array ($result2, MYSQL_NUM);
    
    if (isset($_POST['submitted'])){
       $errors = array();
    
       if (empty($_POST['cat'])){
          $errors[] = '<p>Please select a Category!</p>';
       } else {
          if (strlen($_POST['cat']) <= 4){
          $cat = escape_data($_POST['cat']); 
    	  } else {
    	  $errors[] = '<p>Category is invalid!</p>';
    	  } 
       }
    	
       if (empty($_POST['fsb'])){
          $errors[] = '<p>Please select a For Sale By!</p>';
       } else {
          if (strlen($_POST['fsb']) <= 7){
          $fsb = escape_data($_POST['fsb']); 
    	  } else{
    	  $errors[] = '<p>For Sale By is invalid!</p>';
    	  } 
       }
       
       if (empty($_POST['type'])){
          $errors[] = '<p>Please select a Type!</p>';
       } else {
          if (strlen($_POST['type']) <= 18){
          $type = escape_data($_POST['type']); 
    	  } else{
    	  $errors[] = '<p>Type is invalid!</p>';
    	  } 
       }
       
       if (empty($_POST['sqft'])){
          $errors[] = '<p>Please enter the SqFt!</p>';
       } else {
          $sqft = str_replace(",", "", $_POST['sqft']);
          if (strlen($sqft) <= 5 && is_numeric($sqft)){
          $sqft = escape_data($sqft); 
    	  } else{
    	  $errors[] = '<p>SqFt are invalid!</p>';
    	  } 
       }
       
       if (empty($_POST['year'])){
          $errors[] = '<p>Please select the Year built!</p>';
       } else {
          if ($_POST['year'] >= 1900 && $_POST['year'] <= 2011 && is_numeric($_POST['year'])){
          $year = escape_data($_POST['year']); 
    	  } else{
    	  $errors[] = '<p>Year is invalid!</p>';
    	  } 
       }
       
       if (empty($_POST['mls'])){
          $mls = "NULL";
       } else {
          if (is_numeric($_POST['mls']) && strlen($_POST['mls']) <= 8){
          $mls = "'" . escape_data($_POST['mls']) . "'"; 
    	  } else{
    	  $errors[] = '<p>MLS number is invalid!</p>';
    	  } 
       }
       
       if (empty($_POST['street'])){
          $errors[] = '<p>Please enter the Street!</p>';
       } else {
          if (strlen($_POST['street']) <= 45){
          $street = escape_data($_POST['street']); 
    	  } else{
    	  $errors[] = '<p>Street is invalid!</p>';
    	  } 
       }
       
       if (empty($_POST['city'])){
          $errors[] = '<p>Please enter the City!</p>';
       } else {
          if (strlen($_POST['city']) <= 45){
          $city = escape_data($_POST['city']); 
    	  } else{
    	  $errors[] = '<p>City is invalid!</p>';
    	  } 
       }
       
       if (empty($_POST['state'])){
          $errors[] = '<p>Please select the State!</p>';
       } else {
          if (strlen($_POST['state']) <= 2){
          $state = escape_data($_POST['state']); 
    	  } else{
    	  $errors[] = '<p>State is invalid!</p>';
    	  } 
       } 
       
       if (empty($_POST['zip'])){
          $errors[] = '<p>Please enter the Zip Code!</p>';
       } else {
          if (is_numeric($_POST['zip']) && strlen($_POST['zip']) <= 5){
          $zip= escape_data($_POST['zip']); 
    	  } else{
    	  $errors[] = '<p>Zip Code is invalid!</p>';
    	  } 
       }
       
       if (empty($_POST['ac']) && empty($_POST['phone1']) && empty($_POST['phone2'])){
          $errors[] = '<p>Please enter a Phone Number!</p>';
       } else {
          if (is_numeric($_POST['ac'])){
             if (strlen($_POST['ac']) <= 3){ 
    		    $ac = $_POST['ac'];
    	     } else {
    	        $errors[] = '<p>Area Code is invalid!</p>';
             }
          } else {
    	     $errors[] = '<p>Please enter an Area Code!</p>';
    	  }
    	  
          if (is_numeric($_POST['phone1']) && is_numeric($_POST['phone2'])){
    	     $phone = $_POST['phone1'] . $_POST['phone2'];
             if (strlen($phone) <= 7){ 
    		    $pn = $ac . $phone;
    	     } else {
    	        $errors[] = '<p>Phone Number is invalid!</p>';
             }
          }
       }
       
       if (empty($_POST['price'])){
          $errors[] = '<p>Please enter the Price!</p>';
       } else {
          $p = str_replace(",", "", $_POST['price']);
          if (strlen($p) <= 14 && is_numeric($p)){
    	     if ($cat == 'Rent'){
                $p = '$'.number_format(escape_data($p)).'/mo'; 
    		 } else {
    		    $p = escape_data($p);
    		 }
    	  } else{
    	     if (strtolower($_POST['price']) == 'please contact'){
    		    $p = 'Please Contact';
    		 } else {
    	        $errors[] = '<p>Price is invalid!</p>';
    		 }
    	  } 
       }
       
       if (empty($_POST['title'])){
          $errors[] = '<p>Please enter a Title!</p>';
       } else {
          if (strlen($_POST['title']) <= 60){
          $ti = escape_data($_POST['title']); 
    	  } else{
    	  $errors[] = '<p>Title is too long!</p>';
    	  } 
       }
       
       if (empty($_POST['desc'])){
          $errors[] = '<p>Please enter a Description!</p>';
       } else {
          if (strlen($_POST['desc']) <= 1600){
          $desc = escape_data($_POST['desc']); 
    	  } else{
    	  $errors[] = '<p>Description is too long!</p>';
    	  } 
       }
       
       if (empty($errors)) { //If everything's OK.
       
          $query = "SELECT city, state, zone FROM zips WHERE zip='$zip'";
    	  $result = mysqli_query ($dbc, $query) or DIE;
    	  if (mysqli_num_rows($result) == 1) {
    	     $row = mysqli_fetch_array ($result,MYSQL_NUM);
    		 $cs = $row[0] . ', ' . $row[1];
    		 $z = $zip;
    		 $lz = $row[2];
    		 
    		 $query = "UPDATE `re` SET `title`='$ti', `description`='$desc', `price`='$p', `cs`='$cs', `zip`='$z', `region`='$lz', `pn`='$pn' WHERE `ad_id`=$a AND `user_id`=" . $_SESSION['user_id'];
    		 mysqli_query ($dbc, $query);
    		 
    		 $query = "UPDATE `$sc` SET `cat`='$cat', `fsb`='$fsb', `type`='$type', `sqft`='$sqft', `year`='$year', `mls`=$mls, `street`='$street', `city`='$city', `state`='$state', `zip`='$zip' WHERE `ad_id`=$a";
    		 mysqli_query ($dbc, $query);
    		 
    		 if ($rdir == 1){
    		    $url = "http://post.raptorads.com/realestate/ad_preview.php?a=$a&t=$t&k=$k";
    			header("Location: $url");
    	     } else {
    		    $url = "http://account.raptorads.com";
    			header("Location: $url");
    	     }
          } else {
    	     $errors[] = '<p>This zip code is not in our database!</p>';
          } 
       }
    }
    
    require_once('/home/david/includes/header3.htm');
    
    require_once('/home/david/includes/session.inc.php');
    ?>
     
    <div id="middle">
    <?php
    
    echo '<div class="ad_upload">' . "\n";
    
    if (isset($_POST['submitted'])){
       if ($errors){ // If one of the data tests failed.
          echo ' <div class="errors">' . "\n";
    	  echo '  <h2>Error!</h2>' . "\n";
          foreach ($errors as $msg) { // Print each error.
                   echo "  $msg\n";
          }
    	  echo ' </div>' . "\n";
       }      
    }
    
    ?>
    
    <h3>Property Details</h3>
    <p>* = required field</p>
    <form name="re" method="POST" action="<?php echo $furl; ?>">
    <table>
    <tr>
    <th>*Category</th>
    <td>
    <select name="cat">
      <option value="">Choose a Category</option>
    <?php
    $a = array("Own", "Rent");
    for ($i = 0; $i <= 1; $i++){
       echo '  <option value="' . $a[$i] . '"';
       if (isset($_POST['cat']) && $_POST['cat'] == $a[$i]){ 
          echo ' selected="selected"';
       } else {
          if ($row2[0] == $a[$i]){
    	     echo ' selected="selected"';
    	  }
       }
       echo '>' . $a[$i] . "</option>\n";
    }
    ?>
    </select>
    </td>
    </tr>
    <tr>
    <th>*For Sale By</th>
    <td>
    <select name="fsb">
      <option value="">For Sale By?</option>
    <?php
    $a = array("Agent", "Owner");
    for ($i = 0; $i <= 1; $i++){
       echo '  <option value="' . $a[$i] . '"';
       if (isset($_POST['fsb']) && $_POST['fsb'] == $a[$i]){ 
          echo ' selected="selected"';
       } else {
          if ($row2[1] == $a[$i]){
    	     echo ' selected="selected"';
    	  }
       }
       echo '>' . $a[$i] . "</option>\n";
    }
    ?>
    </select>
    </td>
    </tr>
    <tr>
    <th>*Type</th>
    <td>
    <select name="type">
      <option value="">Choose a Type</option>
    <?php
    $a = array("Apartment Building", "Office Building", "Retail Building", "Warehouse");
    for ($i = 0; $i <= 3; $i++){
       echo '  <option value="' . $a[$i] . '"';
       if (isset($_POST['type']) && $_POST['type'] == $a[$i]){ 
          echo ' selected="selected"';
       } else {
          if ($row2[2] == $a[$i]){
    	     echo ' selected="selected"';
    	  }
       }
       echo '>' . $a[$i] . "</option>\n";
    }
    ?>
    </select>
    </td>
    </tr>
    <tr>
    <th>*Year Built</th>
    <td>
    <select name="year">
      <option value="">Choose a Year</option>
    <?php
    for ($i = 2011; $i >= 1900; $i--){
       echo '  <option value="' . $i . '"';
       if (isset($_POST['year']) && $_POST['year'] == $i){ 
          echo ' selected="selected"';
       } else {
          if ($row2[4] == $i){
    	     echo ' selected="selected"';
    	  }
       }
       echo '>' . $i . "</option>\n";
    }
    ?>
    </select>
    </td>
    </tr>
    <tr>
    <th>*SqFt.</th>
    <td>
    <input type="text" name="sqft" value="<?php if (isset($_POST['sqft'])){echo htmlspecialchars($_POST['sqft']);}else{ echo $row2[3];}?>" maxlength="6" />
    </td>
    </tr>
    <tr>
    <th>MLS number</th>
    <td>
    <input type="text" name="mls" value="<?php if (isset($_POST['mls'])){echo htmlspecialchars($_POST['mls']);}else{ echo $row2[5];}?>" maxlength="8" />
    </td>
    </tr>
    </table>
    <img src="http://raptorads.com/images/graphics/hr.gif" width="940" height="5" alt="" border="0" />
    <h3>Address of Property</h3>
    <div class="address">
       <div class="street">
       <label for="street">*Street</label>
       <input type="text" name="street" value="<?php if (isset($_POST['street'])){echo htmlspecialchars($_POST['street']);}else{ echo $row2[6];?>" maxlength="45" id="street" />
       </div>
       
       <div class="city">
       <label for="city">*City</label>
       <input type="text" name="city" id="city" value="<?php if (isset($_POST['city'])){echo htmlspecialchars($_POST['city']);}else{ echo $row2[7];}?>" maxlength="45" />
       </div>
       
       <div class="state">
       <label for="state">*State</label>
       <select name="state" id="state">
          <option selected value="">-Select-</option>
    <?php
    $a = array("AL", "FL", "GA");
    for ($i = 0; $i <= 2; $i++){
       echo '  <option value="' . $a[$i] . '"';
       if (isset($_POST['state']) && $_POST['state'] == $a[$i]){ 
          echo ' selected="selected"';
       } else {
          if ($row2[8] == $a[$i]){
    	     echo ' selected="selected"';
    	  }
       }
       echo '>' . $a[$i] . "</option>\n";
    }
    ?>
       </select>
       </div>
       
       <div class="zip">
       <label for="zip">*Zip</label>
       <input type="text" name="zip" id="zip" value="<?php if (isset($_POST['city'])){echo htmlspecialchars($_POST['city']);}else{ echo $row2[9];}?>" maxlength="5" />
       </div>
    </div>
    <img src="http://raptorads.com/images/graphics/hr.gif" width="940" height="5" alt="" border="0" />
    <h3>Ad Information</h3>
       <div class="phone">
        <label>*Phone #</label>
        (<input type="text" style="width:30px" name="ac" value="<?php if (isset($_POST['ac'])){echo htmlspecialchars($_POST['ac']);}else{echo $pn[0];}?>" maxlength="3" />) <input type="text" style="width:30px" name="phone1" value="<?php if (isset($_POST['phone1'])){echo htmlspecialchars($_POST['phone1']);}else{echo $pn[1];}?>" maxlength="3" /> - <input type="text" style="width:50px" name="phone2" value="<?php if (isset($_POST['phone2'])){echo htmlspecialchars($_POST['phone2']);}else{echo $pn[2];}?>" maxlength="4" />
       </div>
    <table>
    <tr>
    <th>*Price</th>
    </tr>
    <tr>
    <td style="padding: 0;">
    $<input type="text" class="small-input" name="price" value="<?php if (isset($_POST['price'])){echo htmlspecialchars($_POST['price']);}else{ echo $np;}?>" maxlength="14" /><br />
    <span>e.g. (1234 or please contact)</span>
    </td>
    </tr>
    <tr>
    <th>*Title</th>
    </tr>
    <tr>
    <td style="padding: 0;" colspan="2">
    <input type="text" class="large-input" name="title" value="<?php if (isset($_POST['title'])){echo htmlspecialchars($_POST['title']);}else{ echo $row1[0];}?>" maxlength="60" />
    </td>
    </tr>
    <tr>
    <th>*Description</th>
    </tr>
    <tr>
    <td style="padding: 0;" colspan="2">
    <textarea name="desc" onKeyDown="textCounter(document.re.desc,document.re.remLen2,1600)" onKeyUp="textCounter(document.re.desc,document.re.remLen2,1600)"><?php if (isset($_POST['city'])){echo htmlspecialchars($_POST['city']);}else{ echo $row1[1];}?></textarea><br />
    <input readonly type="text" name="remLen2" maxlength="4" value="1600" class="tiny-input">
    characters remaining
    </td>
    </tr>
    </table>
    <input type="hidden" name="submitted" value="TRUE" />
    <input type="submit" value="Save Changes">
    </form>
    </div>
    
    </div><!-- End of Middle div-->
    
    <?php
    require_once('/home/david/includes/footer2.htm');
    ?>
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    You missed a curly braces somewhere. The placement of which could depend on your code, so trace your curly braces {} and pair them up until you find the missing one.

    Dan

    Comment

    • David Morris
      New Member
      • Nov 2010
      • 4

      #3
      I have checked and rechecked and I still can't find it.

      Comment

      • David Morris
        New Member
        • Nov 2010
        • 4

        #4
        I found it!!! I just kept removing sections of code until I found the section it was in. FYI its on line 458. Thanks for the help!

        Comment

        • John Doe
          New Member
          • Jun 2011
          • 20

          #5
          David,

          The closing curly brace is missing from line 458, just after the $row2[6];

          Lol, looks like you found it while I was looking too.

          Comment

          • David Morris
            New Member
            • Nov 2010
            • 4

            #6
            lol Thanks anyway it was a hard one for me to find.

            Comment

            Working...