How to change theme programmatically from a external application?

Take a look at the options table:

$opt_table = "{$GLOBALS['wpdb']->prefix}_options";
$parent_theme = $opt_table + template;
$child_theme = $opt_table + stylesheet;

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