Preferred way of cacheing a value in php

You want the Transients API: get_transient and set_transient (and get/set_site_transient).

These store values in the wp_options table with a namespace and expiry date, so they do persist through page reloads. (As does anything stored in the database, unless you explicitly create per-connection temporary tables.)

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