I'm using a MySQL database on localhost and I'm trying to upload some world data. When I run the code below it creates the forms but then they don't get filled.
I tested the file reading. It was able to echo out the name, region, lat, and lng just fine.
<?php
require_once 'connect.ini.php';
$file_names = scandir('Countries');
foreach ($file_names as &$file_name)
if ($file_name != '.' && $file_name != '..') {
$file_path = '/Applications/XAMPP/xamppfiles/htdocs/series/dbsetup/Countries/'.$file_name;
$file_handle = fopen("$file_path", "r");
$sql = $sql = "CREATE TABLE `countries1`.`$file_name` (`id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(20) NOT NULL, `region` VARCHAR(20) NOT NULL, `latitude` FLOAT(15) NOT NULL, `longitude` FLOAT(15) NOT NULL) ENGINE = MyISAM;";
mysql_query($sql);
while(!feof($file_handle)) {
$explode = explode(", ", fgets($file_handle));
$name = $explode[0];
$region = $explode[1];
$latitude = $explode[2];
$longitude = $explode[3];
$sql = "INSERT INTO `countries1`.`$file_name` (`id`, `name`, `region`, `latitude`, `longitude`) VALUES (NULL, \'$name\', \'$region\', \'$latitude\', \'$longitude\');";
mysql_query($sql);
}
}
?>
Below is my connect.ini.php file although I'm pretty sure it's working because it is creating the forms.
<?php
$conn_error='Could not connect.';
$mysql_host='localhost';
$mysql_user='root';
$mysql_pass='';
$mysql_db='a_database';
if(!(@mysql_connect($mysql_host,$mysql_user,$mysql_pass)&&@mysql_select_db($mysql_db)))
die($conn_error);
?>