title: mysql_insert_id() returns 0
body: <p>I know there are a lot of topics with the same title. But mostly it's the query that's been inserted in the wrong place. But I think I placed it right. 
  So the problem is, that I still get 0 even when the data is inserted in the db. 
  Does someone knows an answer where I could be wrong?</p>
  
  <p>here's my code: </p>
  
  <pre><code>mysql_query('SET NAMES utf8');
      $this-&gt;arr_kolommen = $arr_kolommen;
      $this-&gt;arr_waardes = $arr_waardes;
      $this-&gt;tabel = $tabel;
      $aantal = count($this-&gt;arr_kolommen);
      //$sql="INSERT INTO `tbl_photo_lijst_zoekcriteria` ( `PLZ_FOTO` , `PLZ_ZOEKCRITERIA`,`PLZ_CATEGORIE`)VALUES ('$foto', '$zoekje','$afdeling');";
      $insert = "INSERT INTO ".$this-&gt;tabel." ";
      $kolommen = "(";
      $waardes = " VALUES(";
      for($i=0;$i&lt;$aantal;$i++)
      {
          $kolommen .=$this-&gt;arr_kolommen[$i].",";
          $waardes .="'".$this-&gt;arr_waardes[$i]."',";
      }
      $kolommen = substr($kolommen,0,-1).")";
      $waardes = substr($waardes,0,-1).")";
      $insert .=$kolommen.$waardes;   
      $result = mysql_query($insert,$this-&gt;db)  or die ($this-&gt;sendErrorToMail(str_replace("  ","",str_replace("\r\n","\n",$insert))."\n\n".str_replace(" ","",str_replace("\r\n","\n",mysql_error()))));
      $waarde = mysql_insert_id();
  </code></pre>
  
  <p>Thanks a lot in advance, because I have been breaking my head for this one for almost already a whole day. (and probably it's something small and stupid)</p>