Convert the_permalink() function output into string

Use get_permalink() function which returns a value instead of printing it.

Example –

$permalink = get_permalink($id); //$id if using outside loop

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