I want to retrieve the latest autoincremented id of the record which i have inserted, so that i can use it update query.
I used last_insert_id() but it seems to be not working.Please help as i m still learning PHP
here's the code..
$insert = "INSERT INTO `farmlogin` (`uid`, `name`, `gender`, `date`, `age`, `bb`, `htno`, `htunit`, `lno`, `lunit`, `pric`, `clr`, `insured`,
`inscomp`, `polname`, `premiumtype`, `premiumamt`, `insstdate`, `matdate`, `remk`) VALUES ('$d', '$n', '$gen', '$dt', '$umar', '$bo', '$hgt', '$unitht', '$lgt', '$unitl', '$pr', '$colo', '$check', '$cname', '$poly', '$premtype', '$amt', '$insurancedat', '$mat', '$rk')";
$result = mysql_query($insert);
$id = intval($_GET['id']);
$sql = "UPDATE `farmlogin` SET `doccity`='$id' WHERE `cowid`='last_insert_id($result)'";
echo "$sql";
$data = mysql_query($sql);
if($result)
{
echo "<script>location.href='http://localhost/assigndoc.php'</script>";
}
else
{
echo "sami";
}