miczja94 I had the same issue, it's fixed by manually adding your table prefix (flarum_) to all table names after INSERT INTO.
For example:
$query = "INSERT INTO users (id, username, email, password, join_time, is_activated) VALUES ( '$id', '$formatedUsername', '$email', '$password', '$jointime', 1)";
Becomes
$query = "INSERT INTO flarum_users (id, username, email, password, join_time, is_activated) VALUES ( '$id', '$formatedUsername', '$email', '$password', '$jointime', 1)";