The logical error is when I will update the field from the database it displays an error like this:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\maritime_database\subject_entry.php on line 79
Subjects Entry
The reason maybe because the subject code starts with a letter. It works fine when the subject code starts with a number but I want it also to work with a letter.
here's my code:
<?php
if($opr=="upd")
{
$sql_upd=mysql_query("SELECT * FROM subjects WHERE sub_code=$id");
$rs_upd=mysql_fetch_array($sql_upd); // it displays an error
?>
div id="style_informations">
<form method="post">
<div>
<table border="0" cellpadding="5" cellspacing="0">
<tr>
<td>Subject Code</td>
<td>
<input type="text" name="sub_code_txt" id="textbox" value="<?php echo $rs_upd['sub_code'];?>" />
</td>
</tr>
<tr>
<td>Semester</td>
<td>
<input type="text" name="semestertxt" id="textbox" value="<?php echo $rs_upd['semester'];?>" />
</td>
</tr>
<tr>
<td>Subjects's name</td>
<td>
<input type="text" name="subtxt" id="textbox" value="<?php echo $rs_upd['subject_name'];?>" />
</td>
</tr>
<tr>
<td>Units</td>
<td>
<input type="text" name="subtxt" id="textbox" value="<?php echo $rs_upd['units'];?>" />
</td>
</tr>
<tr>
<td>Note</td>
<td>
<textarea name="notetxt" cols="23" rows="3"><?php echo $rs_upd['note'];?></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<input type="reset" value="Cancel" id="button-in"/>
<input type="submit" name="btn_upd" value="Update" id="button-in" />
</td>
</tr>
</table>
</div>
</form>