What are common reasons for the error "supplied argument is not a valid MySQL-Link resource" when using MySQL functions in PHP?

The error "supplied argument is not a valid MySQL-Link resource" typically occurs when the MySQL connection is not properly established before executing MySQL functions in PHP. To solve this issue, make sure to establish a valid MySQL connection using functions like `mysqli_connect()` or `mysqli_init()` before using MySQL functions.

// Establish MySQL connection
$mysqli = mysqli_connect("localhost", "username", "password", "database");

// Check if the connection is valid
if (!$mysqli) {
    die("Connection failed: " . mysqli_connect_error());
}

// Now you can use MySQL functions with the $mysqli object
mysqli_query($mysqli, "SELECT * FROM table_name");