WordPress add_rewrite_rule with 2 variables

After lots of pulling my hair out I figured out the problem.

I needed to use the add_rewrite_tag() function to tell wordpress to allow my query vars.

function prefix_movie_rewrite_rule() {

add_rewrite_tag('%state_id%', '([A-Za-z0-9\-\_]+)');
add_rewrite_tag('%state%', '([A-Za-z0-9\-\_]+)');
add_rewrite_rule ( 'states/([A-Za-z0-9\-\_]+)/([A-Za-z0-9\-\_]+)', 'index.php? 
state_id=$matches[1]&state=$matches[2]', 'top' );

}

add_action( 'init', 'prefix_movie_rewrite_rule');

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