Cannot access $wpdb, comes back NULL

As stated in the Comments, do not access a plugin file directly. Instead, use other means that incorporate the REST API or the included Ajax functionality in WordPress. To learn how to use Ajax in your Plugin, have a look here: Ajax in Plugins

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