This usually happens when required fields are omitted from the insert and the insert fails.
You can debug this by adding code after line 17:
$InsertQuery->execute();
var_dump($InsertQuery);
die();
That will show you information about the insert including any errors and should give you the information you need to make it work.