title: (php) can't get id from table
body: <p>I have two tables and I want to add data to the first table and get <code>id</code> of the newly inserted data from <code>first table</code> and use it to add the data to <code>second table</code></p>
  
  <pre><code>$statement = $dbh-&gt;prepare("INSERT INTO sis_university (name,site,tel,email,adress) VALUES (:name,:site,:tel,:email,:adress);");
      if($statement-&gt;execute(array(':name' =&gt; $name,':site' =&gt; $site,':tel' =&gt; $tel,':email' =&gt; $email, ':adress' =&gt; $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-&gt;prepare("INSERT INTO sis_admin (username,password,name,tel,email,adress,type,universityid) VALUES (:username,:password,:name,:tel,:email,:adress,:type,:universityid);");
          if($statement-&gt;execute(array(':username' =&gt; $username,':password' =&gt; $password,':name' =&gt; $adminname,':tel' =&gt; $admintel, ':email' =&gt; $adminemail, ':adress' =&gt; $adminadress, ':type' =&gt; $admintype, ':universityid' =&gt; $uniid))){
              echo "success";
          }else{
              echo "failure" . " " . $uniid;
          }
      }else{
          echo "failure";
      } 
  </code></pre>
  
  <p>data is been added successfully into first table but <code>$uniid</code> is null and data is not getting added to second teble</p>