What best practices should be followed when naming tables in a MySQL database to avoid errors in PHP scripts?

When naming tables in a MySQL database to be used in PHP scripts, it is important to follow best practices to avoid errors. Tables should have descriptive names that are easy to understand and follow a consistent naming convention. Avoid using reserved words or special characters in table names to prevent syntax errors in PHP scripts.

// Example of creating a table with a descriptive name in a MySQL database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

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

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

// SQL query to create a table with a descriptive name
$sql = "CREATE TABLE users (
    id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    firstname VARCHAR(30) NOT NULL,
    lastname VARCHAR(30) NOT NULL,
    email VARCHAR(50),
    reg_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)";

if ($conn->query($sql) === TRUE) {
    echo "Table users created successfully";
} else {
    echo "Error creating table: " . $conn->error;
}

$conn->close();