How to detect where the $end error in php is exactly is
<p>I'm having trouble with this error in php:</p>

<pre><code> Parse error: syntax error, unexpected $end in J:\Server\xampplite\htdocs\exp\printact.php  on line 172
</code></pre>

<p>It might be a lack of bracket or something. Is there any tool that could help me pin point where exactly the error is?</p>

<p>EDIT:
Here's the code, its a mess:)</p>

<pre><code>&lt;link rel="stylesheet" href="print.css" type="text/css" media="print" /&gt;

&lt;font size="3"&gt;&lt;center&gt;&lt;b&gt;XD627 INFORMATION MANAGEMENT SYSTEM&lt;/b&gt;&lt;/center&gt;&lt;/font&gt;

&lt;br /&gt;
&lt;br /&gt;

&lt;div id="max"&gt;






    &lt;?php
$con = mysql_connect("localhost","root","nitoryolai123$%^");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("school", $con);
?&gt; 



&lt;?php 

$ShowImage= ( $_POST['pic'] == 'pix');


$ShowFirstName = ( $_POST['fname'] == 'firstname');

$ShowLastName = ( $_POST['lname'] == 'lastname');

$ShowMidName = (  $_POST['mname'] == 'midname');

$ShowAddress = (  $_POST['ad'] == 'address');

$ShowGender = ( $_POST['gender'] == 'gen');


$ShowReligion = (  $_POST['rel'] == 'religion');

$ShowBday = (   $_POST['bday'] == 'birthday');

$ShowContact = (   $_POST['contact'] == 'contactnum');

$ShowMother = (   $_POST['mother'] == 'ma');

$ShowMotherOcc = (  $_POST['mother_occ'] == 'ma_occ');

$ShowFather = (   $_POST['father'] == 'pa');

$ShowFather_Occ = (  $_POST['father_occ'] == 'pa_occ');

$ShowParentAddress = (  $_POST['parent_add'] == 'pad');


$ShowParentContact = (  $_POST['parent_contact'] == 'pcon');

$id =  mysql_real_escape_string($_POST['idnum']); 
$result2 = mysql_query("SELECT * FROM student WHERE IDNO='$id'"); 
$result3 = mysql_query("SELECT * FROM mother WHERE IDNO='$id'");
$result4 = mysql_query("SELECT * FROM father WHERE IDNO='$id'");
$result5 = mysql_query("SELECT * FROM parents WHERE IDNO='$id'");
?&gt;

&lt;?php while($row = mysql_fetch_array($result2)) 
{ 
?&gt;

&lt;font size="2"&gt;&lt;b&gt;&lt;u&gt;Student Information&lt;/br&gt;&lt;/b&gt;&lt;/u&gt;&lt;/font&gt;&lt;br&gt;

&lt;?php if( $ShowImage ) ?&gt; 
 &lt;?php echo "&lt;img src='http://localhost/exp/upload/$sidno.jpg'&gt;"; ?&gt; &lt;br&gt;&lt;br&gt;

  &lt;font size="1"&gt;&lt;B&gt;ID Number:&lt;/B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;?php echo $row['IDNO']; ?&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;

  &lt;font size="1"&gt;&lt;B&gt;&lt;B&gt;Year:&lt;/B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;?php echo $row['YEAR']; ?&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br&gt;
     &lt;B&gt;Section:&lt;/B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;?php echo $row['SECTION']; ?&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;


&lt;?php if( $ShowLastName ) ?&gt;
  &lt;font size="1"&gt;&lt;B&gt;Lastname:&lt;/B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;?php echo $row['LASTNAME']; ?&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;

  &lt;?php   if( $ShowFirstName ) ?&gt;
         &lt;font size="1"&gt;&lt;B&gt;&lt;B&gt;Firstname:&lt;/B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;?php echo $row['FIRSTNAME']; ?&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;

 &lt;?php if( $ShowMidName ) ?&gt;
         &lt;font size="1"&gt;&lt;B&gt;&lt;B&gt;Midname:&lt;/B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;?php echo $row['MI']; ?&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;


    &lt;?php if( $ShowAddress ) ?&gt;
         &lt;font size="1"&gt;&lt;B&gt;&lt;B&gt;Address:&lt;/B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;?php echo $row['ADDRESS']; ?&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;


    &lt;?php if( $ShowGender ) ?&gt;
         &lt;font size="1"&gt;&lt;B&gt;&lt;B&gt;Gender:&lt;/B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;?php echo $row['GENDER']; ?&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;




    &lt;?php if( $ShowReligion ) ?&gt;
         &lt;font size="1"&gt;&lt;B&gt;&lt;B&gt;Religion:&lt;/B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;?php echo $row['RELIGION']; ?&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;


    &lt;?php if( $ShowBday ) ?&gt;
         &lt;font size="1"&gt;&lt;B&gt;&lt;B&gt;Birthday:&lt;/B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;?php echo $row['BIRTHDAY']; ?&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;


    &lt;?php if( $ShowContact) ?&gt;
         &lt;font size="1"&gt;&lt;B&gt;&lt;B&gt;Contact Number&lt;/B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;?php echo $row['S_CONTACTNUM']; ?&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;


&lt;?php } ?&gt;


&lt;?php while($row = mysql_fetch_array($result3)) 
{ 
?&gt;
  &lt;br&gt;
&lt;br&gt;
 &lt;?php if( $ShowMother or $ShowFather or $ShowMotherOcc or $ShowFather_Occ  or $ShowParentAddress or $ShowParentContact ) ?&gt;

&lt;font size="3"&gt;&lt;b&gt;&lt;u&gt;Parent Information&lt;/br&gt;&lt;/b&gt;&lt;/u&gt;&lt;/font&gt;&lt;br&gt;


   &lt;tr&gt;
     &lt;?php  if( $ShowMother ) ?&gt;

         &lt;font size="1"&gt;&lt;B&gt;&lt;B&gt;Mother:&lt;/B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;?php echo $row['MOTHER']; ?&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;


    &lt;?php     if( $ShowMotherOcc ) ?&gt;
         &lt;font size="1"&gt;&lt;B&gt;&lt;B&gt;Mother Occupation:&lt;/B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;?php echo $row['MOTHER_OCCUPATION']; ?&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
}


&lt;?php  while($row = mysql_fetch_array($result4)) 
{  ?&gt;

        &lt;?php   if( $ShowFather ) ?&gt;
         &lt;font size="1"&gt;&lt;B&gt;&lt;B&gt;Father:&lt;/B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;?php echo $row['FATHER']; ?&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;

         &lt;?php  if( $ShowFather_Occ ) ?&gt;
         &lt;font size="1"&gt;&lt;B&gt;&lt;B&gt;Father Occupation:&lt;/B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;?php echo $row['FATHER_OCCUPATION']; ?&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;

&lt;?php } ?&gt;
&lt;?php while($row = mysql_fetch_array($result5)) 
{ ?&gt;
        &lt;?php   if( $ShowParentAddress ) ?&gt;
         &lt;font size="1"&gt;&lt;B&gt;&lt;B&gt;Parent Address:&lt;/B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;?php echo $row['P_ADDRESS']; ?&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;


         &lt;?php    if( $ShowParentContact ) ?&gt;
         &lt;font size="1"&gt;&lt;B&gt;&lt;B&gt;Parent Contact:&lt;/B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;?php echo $row['P_CONTACTNUM']; ?&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;


&lt;?php } ?&gt; 


&lt;?php mysql_close($con);  ?&gt; 
&lt;/div&gt;
&lt;div id="nav"&gt;
&lt;form&gt;
&lt;input type="button" value="Print" onClick="window.print();" /&gt; 
&lt;/form&gt;
&lt;/div&gt;
</code></pre>
