The error message basically says that $wpdb
is not an object so you can’t call any methods on it. As we can’t see where $wpdb
is defined in the source you posted it’s hard to tell any further details.
Are you even including wordpress in your external file? You need to require wp-load.php
to use the wordpress functions and classes in an external application.