What are the potential pitfalls of using reserved words like "Text" as column names in a MySQL database when working with PHP?

Using reserved words like "Text" as column names in a MySQL database can lead to syntax errors when querying the database in PHP. To avoid this issue, you can enclose the column name in backticks (`) in your SQL queries.

<?php

// Connect to the database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Query the database using backticks for the column name
$sql = "SELECT `Text` FROM myTable";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // Output data of each row
    while($row = $result->fetch_assoc()) {
        echo "Text: " . $row["Text"] . "<br>";
    }
} else {
    echo "0 results";
}

$conn->close();

?>