0

I'm getting an error which says:

Parse error: syntax error, unexpected $end in /home/Jones/public_html/Assignment4/listCar.php on line 38

However, there is nothing on line 38.. Thanks

$sql = "SELECT * FROM CARS";
//Get the result set
$result = mysql_query($sql);
//Show the result using while statement and a html table tag
?>
<table border =1>
<tr>
<td> ID </td>
<td> Make </td>
<td> Model </td>
<td> Year </td>
<td> Mileage </td>
<td> First Name </td>
<td> Last Name </td>
<td> Email </td>
</tr>
<?php
while($row = mysql_fetch_array($result)){
echo $row ['ID'];
echo $row['MAKE'];
echo $row['MODEL'];
echo $row[YEAR];
echo $row[MILE];
echo $row['FNAME'];
echo $row['LNAME'];
echo $row['EMAIL'];


?>
}
</html>
chris85
  • 23,846
  • 7
  • 34
  • 51
user5400828
  • 71
  • 1
  • 8
  • 3
    If you're writing new code, **_please_ don't use the `mysql_*` functions**. They are old and broken, were deprecated in PHP 5.5 (which is so old it no longer even receives security updates), and completely removed in PHP 7. Use [`PDO`](https://secure.php.net/manual/en/book.pdo.php) or [`mysqli_*`](https://secure.php.net/manual/en/book.mysqli.php) with _prepared statements_ and _parameter binding_ instead. See http://stackoverflow.com/q/12859942/354577 for details. – ChrisGPT was on strike Dec 05 '16 at 04:09
  • 5
    `}` is on the wrong side of the `?>`. It says line 38 because it has no idea know where you intended to close the loop. For these errors the line numbers aren't useful, follow your indentation and you'll see the issue. You also need to indent your blocks. – chris85 Dec 05 '16 at 04:09

1 Answers1

1
        <?php
       while($row = mysql_fetch_array($result)){
         echo $row ['ID'];
      echo $row['MAKE'];
       echo $row['MODEL'];
        echo $row[YEAR];
      echo $row[MILE];
        echo $row['FNAME'];
        echo $row['LNAME'];
       echo $row['EMAIL'];
       ?>
         }

change it to this

       <?php
        while($row = mysql_fetch_array($result)){
         echo $row ['ID'];
        echo $row['MAKE'];
        echo $row['MODEL'];
       echo $row[YEAR];
      echo $row[MILE];
     echo $row['FNAME'];
       echo $row['LNAME'];
        echo $row['EMAIL'];

    }
         ?>

You have put } bracket after ?> which is giving you unexpected error.

chris85
  • 23,846
  • 7
  • 34
  • 51
rupesh
  • 277
  • 3
  • 15