I have following errors in below coding.

Undefined variables: fname,focu,foad,ftp,fmf,mname,mocu,moad,mtp,mmf,gname,gocu,goadd,gtp,gmf in C:\wamp\www\Student registration\manage studnt parent details\manageStudentRegistrationParentDetailsForm.php

Code

<?php
$query="SELECT state,name,occupation,office_address,office_telephone,mobile_number FROM parent_info
where admission_no='$admission_no'"; 
$result=mysql_query($query);
while($row=mysql_fetch_array($result)){


$first=$row['state'];

if($first=='father'){
    $fname=$row['name'];
    $focu=$row['occupation'];
    $foadd=$row['office_address'];
    $ftp=$row['office_telephone'];
    $fmf=$row['mobile_number'];

}
if($first=='mother'){
    $mname=$row['name'];
    $mocu=$row['occupation'];
    $moadd=$row['office_address'];
    $mtp=$row['office_telephone'];
    $mmf=$row['mobile_number'];
}
if($first=='guardians'){
    $gname=$row['name'];
    $gocu=$row['occupation'];
    $goadd=$row['office_address'];
    $gtp=$row['office_telephone'];
    $gmf=$row['mobile_number'];
}

}

?>
----
----

 <tr>
        <td>&nbsp;</td>
        <td colspan="5"><h3>
          <label><strong>Parents/Guardian information</strong></label>
          <strong>&nbsp;</strong></h3></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2">&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><label>Admission No</label>&nbsp;</td>
        <td colspan="2" align="left"><?php echo $admission_no ;?></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2">&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>

      <tr>
        <td>&nbsp;</td>
        <td colspan="2">
          <input type="checkbox" name="checkbox" id="checkbox" <?php if($fname!=null){ ?> checked="checked" <?php }?> onclick="father()" />
        <label>fathers details</label></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2"><label> Name</label>&nbsp;</td>
        <td><input type="text" name="Name1" id="textfield" value="[B]<?php  echo $fname; ?>[/B]" disabled="disabled" /></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2"><label>Occupation</label>&nbsp;</td>
        <td>

            <input type="text" name="Occupation1" id="textfield2" value="[B]<?php echo $focu; ?>[/B]" disabled="disabled"/>

        </td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2"><label>Office Address</label>&nbsp;</td>
        <td>

            <textarea name="Office_Address1" id="office_address" cols="45" rows="5"  disabled="disabled">[B]<?php echo $foadd; ?>[/B]</textarea>

        </td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2"><label>Office Telephone Number</label>
          &nbsp;</td>
        <td>

            <input type="text" name="Office_tel1" id="textfield4"  value="[B]<?php echo $ftp; ?>[/B]" disabled="disabled" />

        </td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2"><label>Mobile Phone Number</label></td>
        <td>

            <input type="text" name="Mobile_pho1" id="textfield5" value="[B]<?php echo $fmf; ?>[/B]" disabled="disabled" />

        </td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2">&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2">
          <input type="checkbox" name="checkbox2" id="checkbox2" <?php if($mname!=null){ ?> checked="checked" <?php }?> onclick="mother()" />
        <label>Mothers details</label></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2"><label> Name</label>&nbsp;</td>
        <td>
          <input type="text" name="Name2" id="textfield3" value="[B]<?php echo $mname; ?>[/B]" disabled="disabled"/>
        </td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2"><label>Occupation</label>&nbsp;</td>
        <td>
          <input type="text" name="Occupation2" id="textfield7" value="[B]<?php echo $mocu; ?>[/B]" disabled="disabled"/>
        </td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2"><label>Office Address</label>&nbsp;</td>
        <td>
          <textarea name="Office_Address2" id="textarea" cols="45" rows="5" disabled="disabled">[B]<?php echo $moadd; ?>[/B]</textarea>
        </td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2"><label>Office Telephone Number</label>&nbsp;</td>
        <td>
          <input type="text" name="Office_tel2" id="textfield8" value="[B]<?php echo $mtp; ?>[/B]" disabled="disabled" />
        </td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2"><label>Mobile Phone Number</label>&nbsp;</td>
        <td>
          <input type="text" name="Mobile_pho2" id="textfield9" value="[B]<?php echo $mmf; ?>[/B]" disabled="disabled" />
        </td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2">&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2">
          <input type="checkbox" name="checkbox3" id="checkbox3" <?php if($gname!=null){ ?> checked="checked" <?php }?> onclick="Guardian()"/>
        <label>Guardian details</label></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2"><label> Name</label>&nbsp;</td>
        <td>
          <input type="text" name="Name3" id="textfield6" value="[B]<?php echo $gname; ?>[/B]" disabled="disabled"/>
        </td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2"><label>Occupation</label>&nbsp;</td>
        <td>
          <input type="text" name="Occupation3" id="textfield10" value="[B]<?php echo $gocu; ?>[/B]" disabled="disabled"/>
        </td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2"><label>Office Address</label>&nbsp;</td>
        <td>
          <textarea name="Office_Address3" id="textarea2" cols="45" rows="5" disabled="disabled">[B]<?php echo $goadd; ?>[/B]</textarea>
        </td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2"><label>Office Telephone Number</label>&nbsp;</td>
        <td>
          <input type="text" name="Office_tel3" id="textfield11" value="[B]<?php echo $gtp; ?>[/B]" disabled="disabled"/>
        </td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2"><label>Mobile Phone Number</label>&nbsp;</td>
        <td>
          <input type="text" name="Mobile_pho3" id="textfield12" value="[B]<?php echo $gmf; ?>[/B]" disabled="disabled" />
        </td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2">&nbsp;</td>
        <td></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>

      <tr>
        <td>&nbsp;</td>
        <td colspan="2">&nbsp;</td>
        <td>

            <input type="submit" name="button" id="button" value="Save" />

        </td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table>
      <p>&nbsp;</p>
    <p>&nbsp;</p></td>
  </tr>

You can fix it by giving those variables a default value at the top of your script. (Remember to use CODE TAGS)

I have tried following lines. But still does not work.

$fname='';
$focu='';
$foadd='';
$ftp='';
$fmf='';

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.