How do I add a medium to the WordPress database with my own plugin?

After a long search, I finally found the error. It is necessary to use

require "/path/to/wordpress/wp-load.php";

to enable wordpress functions in scripts.

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