次のコードがあります。
<?php
$usStates = array(
'Alabama',
'Alaska',
'Arizona',
'Arkansas',
'California',
'Colorado',
'Connecticut',
'Delaware',
'Florida',
'Georgia',
'Hawaii',
'Idaho',
'Illinois',
'Indiana',
'Iowa',
'Kansas',
'Kentucky',
'Louisiana',
'Maine',
'Maryland',
'Massachusetts',
'Michigan',
'Minnesota',
'Mississippi',
'Missouri',
'Montana',
'Nebraska',
'Nevada',
'New Hampshire',
'New Jersey',
'New Mexico',
'New York',
'North Carolina',
'North Dakota',
'Ohio',
'Oklahoma',
'Oregon',
'Pennsylvania',
'Rhode Island',
'South Carolina',
'South Dakota',
'Tennessee',
'Texas',
'Utah',
'Vermont',
'Virginia',
'Washington',
'West Virginia',
'Wisconsin',
'Wyoming',
);
$link = new mysqli("localhost", "drup197", "*******", "census");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
foreach ($usStates as $state) {
printf("Entering loop\n");
printf("Current state = %s\n", $state);
if (mysqli_query($link, "CREATE TABLE '$state'_age_and_gender_demographics LIKE national_age_and_gender_demographics")) {
printf("%s_age_and_gender_demographics successfully created\n", $state);
}
if (mysqli_query($link, "CREATE TABLE '$state'_race_demographics_-_one_race LIKE national_race_demographics_-_one_race")) {
printf("%s_race_demographics_-_one_race successfully craeted\n");
}
if (mysqli_query($link, "CREATE TABLE '$state'_race_demographics_-_multi-race LIKE national_race_demographics_-_multi-race")) {
printf("%s_race_demographics_-_multi-race successfully craeted\n");
}
if (mysqli_query($link, "CREATE TABLE '$state'_race_demographics_-_hispanic_or_latino LIKE national_race_demographics_-_hispanic_or_latino")) {
printf("%s_race_demographics_-_hispanic_or_latino successfully craeted\n");
}
}
printf("Tables successfuly created");
mysqli_close($link);
?>
基本的に、州の名前をテーブルの名前のワイルドカードとして使用して、50 州すべてのテーブルを作成しようとしています。ただし、これらのクエリは実行されていないようです。問題を教えてください。