I have two tables and I want to add data to the first table and get id
of the newly inserted data from first table
and use it to add the data to second table
$statement = $dbh->prepare("INSERT INTO sis_university (name,site,tel,email,adress) VALUES (:name,:site,:tel,:email,:adress);");
if($statement->execute(array(':name' => $name,':site' => $site,':tel' => $tel,':email' => $email, ':adress' => $adress))){
$sql="SELECT id FROM sis_university WHERE site='$site' LIMIT 1";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$uniid = $row['id'];
$statement = $dbh->prepare("INSERT INTO sis_admin (username,password,name,tel,email,adress,type,universityid) VALUES (:username,:password,:name,:tel,:email,:adress,:type,:universityid);");
if($statement->execute(array(':username' => $username,':password' => $password,':name' => $adminname,':tel' => $admintel, ':email' => $adminemail, ':adress' => $adminadress, ':type' => $admintype, ':universityid' => $uniid))){
echo "success";
}else{
echo "failure" . " " . $uniid;
}
}else{
echo "failure";
}
data is been added successfully into first table but $uniid
is null and data is not getting added to second teble