Dynamically generated URL and Content page

Firstly, don’t forget to always flush your rewrite rules by going to Settings -> Permalinks and just clicking on Save Changes

Now on your problem, it seems that you’re missing an ‘&‘ in your query:

$new_rules['^test-directory/(.*)/(.*)'] = 'index.php?test-directory=$matches[1]&test-code=$matches[2]';

Notice the & after $matches[1]

On the other hand, your ‘template_redirect’ action is not calling the correct function
(template_redirect instead of my_template_redirect)

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