Hi edward,
although Rob Church answered your question, I have two additinal comments.
edward wrote:
$newtitle = "dive-entry-12"; $text = "dit is een blob hoop ik!!"; $sql1 = "insert into text (old_text, old_flags) values ($text, "utf-8")";
Please read [[SQL Injection]].
$sql2 = "select max(old_id) from text"; // result = $page_latest
This is a [[Race Condition]]. Please use $dbw->insertId() (in MediaWiki) or mysql_insert_id for MySQL databases outside of MediaWiki.
Hendrik