Connecting PHP to MySQL (MySQLi & PDO)

This is the most asked question I have seen in the past few months so I thought I would collect some samples here:
This is the most asked question I have seen in the past few months so I thought I would collect some samples here: