i am trying to create a page which loads up some data from a database into a form by looking at the reference code (primary key) which has been passed via the URL. On submitting the form it should update any changes made to the data in the database. I have so far the code below but it does not update the data and comes up with the error :
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\Program Files\Apache Group\Apache2\htdocs\editjobs.php on line 20
<?php include("header.inc");
//open db connection
$link=mysqli_connect('localhost','root','voBtGM','JobBase');
$id= $_GET['ReferenceCode'];
//build and execute query
$select="SELECT JobTitle, Salary, Location, Description FROM Jobs Where $id=ReferenceCode";
$result=mysqli_query($link,$select);
$row=mysqli_fetch_assoc($result);
$JobTitle=$row['JobTitle'];
$Salary=$row['Salary'];
$Location=$row['Location'];
$Description=$row['Description'];?>
<br>
<TABLE border="1">
<TR><TH>Job Title</TH>
<TH>Salary</TH>
<TH>Location</TH>
<TH>Description</TH>
</TR>
<FORM method="post" action="editjobs.php?ReferenceCode=<? echo $ReferenceCode?>">
<TR><TD><input type="text" name="JobTitle" Value="<?echo $JobTitle?>"/></TD>
<TD><input type="text" name="Salary" value="<?echo $Salary?>"/></TD>
<TD><input type="text" name="Location" value="<?echo $Location?>"/></TD>
<TD><input type="text" name="Description" value="<?echo $Description?>"/></TD>
</TR>
</TABLE><br>
<input type="Submit" name="submit" value="Edit Job">
</FORM>
<?if ($_POST) {
//build and execute query
$update="UPDATE Jobs SET JobTitle='$JobTitle', Salary='$Salary', Location='$Location', Description='$Description' WHERE $id=ReferenceCode";
if(!mysqli_query($link,$update)) {
$msg= "Error updating record";
}else{
$msg="Record updated successfully";
}
//print error or success message
echo $msg;
}
//close db connection
mysqli_close($link);?>
</body>
</HTML>