Prevent duplicate pages from being added

you can use the same function simply hook it to the publish_page hook
or any custom post type for that matter publish_{post type name}

so just add :

add_action('publish_page', 'clearDuplicatePosts');

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)