用单引号包装但未包装的数据库名称之间的区别[重复]

This question already has an answer here:

$createPersonTable_SQL = "CREATE TABLE ".$db['database'].".Person ( ";
    $createPersonTable_SQL .= "ID INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , ";
    $createPersonTable_SQL .= "FirstName VARCHAR( 50 ) , ";
    $createPersonTable_SQL .= "LastName VARCHAR( 50 ) NOT NULL , ";
    $createPersonTable_SQL .= "Sex VARCHAR( 4 ) NOT NULL , ";
    $createPersonTable_SQL .= "Age INT( 3 ) NOT NULL , ";
    $createPersonTable_SQL .= "Job VARCHAR( 50 ) NOT NULL , ";
    $createPersonTable_SQL .= "Height float( 2) NOT NULL , ";
    $createPersonTable_SQL .= "Weight float( 2 ) NOT NULL , ";
    $createPersonTable_SQL .= "Hobby VARCHAR( 1000 ) NOT NULL , ";
    $createPersonTable_SQL .= "Salary FLOAT( 2 ) NOT NULL ";
    $createPersonTable_SQL .= ")";

For the first line, if I run the part of the php code like this, table is created successfully. But if I change the first line to "CREATE TABLE '".$db['database']."'.Person ( "; table is created unsuccessfully. Can anyone explain why one version works but the other one doesn't. I run the code using xampp. Thanks!

</div>

The database name cannot be wrapped into single quotes in mysql. You can use backtick if you need to:

$createPersonTable_SQL = "CREATE TABLE `".$db['database']."`.Person ( ";