How can one avoid using reserved words in MySQL queries when writing PHP code?

When writing MySQL queries in PHP code, it is important to avoid using reserved words as column or table names to prevent syntax errors. To avoid this issue, you can either choose different column or table names that are not reserved words, or you can use backticks (`) around the reserved words to escape them in your queries.

$connection = new mysqli("localhost", "username", "password", "database");

// Avoid using reserved words as column or table names
$query = "SELECT `name`, `email` FROM `users` WHERE `status` = 'active'";

$result = $connection->query($query);

if ($result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {
        echo "Name: " . $row["name"] . " - Email: " . $row["email"] . "<br>";
    }
} else {
    echo "No results found.";
}

$connection->close();