Jump to content

Please help me to solve these coding errors


heshan

Recommended Posts

I have following errors in below coding. Can anyone point out me where i went wrong??

 

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

 

 

manageStudentRegistrationParentDetailsForm.php

 

<?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> </td>
<td colspan="5"><h3>
<label><strong>Parents/Guardian information</strong></label>
<strong> </strong></h3></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><label>Admission No</label> </td>
<td colspan="2" align="left"><?php echo $admission_no ;?></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>

<tr>
<td> </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> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label> Name</label> </td>
<td><input type="text" name="Name1" id="textfield" value="<?php echo $fname; ?>" disabled="disabled" /></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>Occupation</label> </td>
<td>

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

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

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

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

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

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

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

</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </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> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label> Name</label> </td>
<td>
<input type="text" name="Name2" id="textfield3" value="<?php echo $mname; ?>" disabled="disabled"/>
</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>Occupation</label> </td>
<td>
<input type="text" name="Occupation2" id="textfield7" value="<?php echo $mocu; ?>" disabled="disabled"/>
</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>Office Address</label> </td>
<td>
<textarea name="Office_Address2" id="textarea" cols="45" rows="5" disabled="disabled"><?php echo $moadd; ?></textarea>
</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>Office Telephone Number</label> </td>
<td>
<input type="text" name="Office_tel2" id="textfield8" value="<?php echo $mtp; ?>" disabled="disabled" />
</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>Mobile Phone Number</label> </td>
<td>
<input type="text" name="Mobile_pho2" id="textfield9" value="<?php echo $mmf; ?>" disabled="disabled" />
</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </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> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label> Name</label> </td>
<td>
<input type="text" name="Name3" id="textfield6" value="<?php echo $gname; ?>" disabled="disabled"/>
</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>Occupation</label> </td>
<td>
<input type="text" name="Occupation3" id="textfield10" value="<?php echo $gocu; ?>" disabled="disabled"/>
</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>Office Address</label> </td>
<td>
<textarea name="Office_Address3" id="textarea2" cols="45" rows="5" disabled="disabled"><?php echo $goadd; ?></textarea>
</td>
<td> </td>
<td> </td>
<td> </td></tr>
<tr>
<td> </td>
<td colspan="2"><label>Office Telephone Number</label> </td>
<td>
<input type="text" name="Office_tel3" id="textfield11" value="<?php echo $gtp; ?>" disabled="disabled"/>
</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr><td> </td>
<td colspan="2"><label>Mobile Phone Number</label> </td>
<td>
<input type="text" name="Mobile_pho3" id="textfield12" value="<?php echo $gmf; ?>" disabled="disabled" />
</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
<td></td>
<td> </td>
<td> </td>
<td> </td>
</tr>

<tr>
<td> </td>
<td colspan="2"> </td>
<td>

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

</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<p> </p>
<p> </p></td>
</tr> 

Link to comment
Share on other sites

Clearly, the conditions are not being met to create them. Check your $row data to make sure it is what it should be.

 

Also, above your loop you can just set all of these variables to an empty value, like $fname = ''; so that if they aren't set to a proper value later, they will still be defined.

Link to comment
Share on other sites

EDITING BECAUSE I Misread your column names... :)

 

yeah -- basically, your IF statement is hitting one of the 3, not all 3, so, if it's "father", mname, and gname is not being set.

 

what you can do rather than:

<?php if($fname!=null){ ?> checked="checked" <?php }?> onclick="father()" />

is:

<?php if(isset($fname)){ ?> checked="checked" <?php }?> onclick="father()" />

 

etc...

 

Link to comment
Share on other sites

Thanks both of u. It solves many problems.. :)

 

But below coding errors are still exist.

 

undefined variables : fname, focu, foadd etc...

 

 

<tr>
        <td> </td>
        <td colspan="2"><label> Name</label> </td>
        <td><input type="text" name="Name1" id="textfield" value="<?php  echo $fname; ?>" disabled="disabled" /></td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td colspan="2"><label>Occupation</label> </td>
        <td>
          
            <input type="text" name="Occupation1" id="textfield2" value="<?php echo $focu; ?>" disabled="disabled"/>
            
        </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td colspan="2"><label>Office Address</label> </td>
        <td>
          
            <textarea name="Office_Address1" id="office_address" cols="45" rows="5"  disabled="disabled"><?php echo $foadd; ?></textarea>
            
        </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td colspan="2"><label>Office Telephone Number</label>
           </td>
        <td>
          
            <input type="text" name="Office_tel1" id="textfield4"  value="<?php echo $ftp; ?>" disabled="disabled" />
            
        </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td colspan="2"><label>Mobile Phone Number</label></td>
        <td>
          
            <input type="text" name="Mobile_pho1" id="textfield5" value="<?php echo $fmf; ?>" disabled="disabled" />
            
        </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td colspan="2"> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td colspan="2">
          <input type="checkbox" name="checkbox2" id="checkbox2" <?php if(isset($mname)){ ?> checked="checked" <?php }?> onclick="mother()" />
        <label>Mothers details</label></td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td colspan="2"><label> Name</label> </td>
        <td>
          <input type="text" name="Name2" id="textfield3" value="<?php echo $mname; ?>" disabled="disabled"/>
        </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td colspan="2"><label>Occupation</label> </td>
        <td>
          <input type="text" name="Occupation2" id="textfield7" value="<?php echo $mocu; ?>" disabled="disabled"/>
        </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td colspan="2"><label>Office Address</label> </td>
        <td>
          <textarea name="Office_Address2" id="textarea" cols="45" rows="5" disabled="disabled"><?php echo $moadd; ?></textarea>
        </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td colspan="2"><label>Office Telephone Number</label> </td>
        <td>
          <input type="text" name="Office_tel2" id="textfield8" value="<?php echo $mtp; ?>" disabled="disabled" />
        </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td colspan="2"><label>Mobile Phone Number</label> </td>
        <td>
          <input type="text" name="Mobile_pho2" id="textfield9" value="<?php echo $mmf; ?>" disabled="disabled" />
        </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td colspan="2"> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td colspan="2">
          <input type="checkbox" name="checkbox3" id="checkbox3" <?php if(isset($gname)){ ?> checked="checked" <?php }?> onclick="Guardian()"/>
        <label>Guardian details</label></td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td colspan="2"><label> Name</label> </td>
        <td>
          <input type="text" name="Name3" id="textfield6" value="<?php echo $gname; ?>" disabled="disabled"/>
        </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td colspan="2"><label>Occupation</label> </td>
        <td>
          <input type="text" name="Occupation3" id="textfield10" value="<?php echo $gocu; ?>" disabled="disabled"/>
        </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td colspan="2"><label>Office Address</label> </td>
        <td>
          <textarea name="Office_Address3" id="textarea2" cols="45" rows="5" disabled="disabled"><?php echo $goadd; ?></textarea>
        </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td colspan="2"><label>Office Telephone Number</label> </td>
        <td>
          <input type="text" name="Office_tel3" id="textfield11" value="<?php echo $gtp; ?>" disabled="disabled"/>
        </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td colspan="2"><label>Mobile Phone Number</label> </td>
        <td>
          <input type="text" name="Mobile_pho3" id="textfield12" value="<?php echo $gmf; ?>" disabled="disabled" />
        </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td colspan="2"> </td>
        <td></td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      
      <tr>
        <td> </td>
        <td colspan="2"> </td>
        <td>
         
            <input type="submit" name="button" id="button" value="Save" />
            
        </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
    </table>
      <p> </p>
    <p> </p></td>
  </tr>

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.