I've gotten import.php working - enough to print out the values in US.txt correctly in arrays onto the screen.
I'm using the below code to try and insert into database:
if(is_readable($filename))
{
$geo = fopen("/home/jharvard/vhosts/pset8/bin/US.txt","r");
while (($lines = fgetcsv($geo, 512, "\t")) !== FALSE)
{
query("INSERT INTO places (id,country_code,postal_code,place_name,admin_name1,admin_code1,admin_name2,admin_code2,admin_name3,admin_code3,latitude,longitude,accuracy) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)",$lines[0],$lines[1],$lines[2],$lines[3],$lines[4],$lines[5],$lines[6],$lines[7],$lines[8],$lines[9],$lines[10],$lines[11],$lines[12]);
}
fclose($geo);
print("Done!");
}
but nothing is inserting and I get the following error code.
jharvard@appliance (~/vhosts/pset8/bin): ./import /home/jharvard/vhosts/pset8/bin/US.txt PHP Notice: Undefined offset: 12 in /home/jharvard/vhosts/pset8/bin/import on line 33 PHP Stack trace: PHP 1. {main}() /home/jharvard/vhosts/pset8/bin/import:0
Notice: Undefined offset: 12 in /home/jharvard/vhosts/pset8/bin/import on line 33
Call Stack: 0.0001 124876 1. {main}() /home/jharvard/vhosts/pset8/bin/import:0
PHP Fatal error: Column 'accuracy' cannot be null in /home/jharvard/vhosts/pset8/includes/functions.php on line 57 PHP Stack trace: PHP 1. {main}() /home/jharvard/vhosts/pset8/bin/import:0 PHP 2. query() /home/jharvard/vhosts/pset8/bin/import:33 PHP 3. trigger_error() /home/jharvard/vhosts/pset8/includes/functions.php:57
Fatal error: Column 'accuracy' cannot be null in /home/jharvard/vhosts/pset8/includes/functions.php on line 57
Call Stack: 0.0001 124876 1. {main}() /home/jharvard/vhosts/pset8/bin/import:0 0.0007 142436 2. query() /home/jharvard/vhosts/pset8/bin/import:33 0.0033 147804 3. trigger_error() /home/jharvard/vhosts/pset8/includes/functions.php:57
I've tried query in a few diffent ways but I can't understand why it won't work.
Thanks