RE: [PHP-DB] Re: No data?

From: Date: Fri, 27 Jul 2012 05:22:46 +0000
Subject: RE: [PHP-DB] Re: No data?
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.db 
Request: Send a blank email to php-db+get-48384@lists.php.net to get a copy of this message
Wow, this is unbeileivable. Your test script fails with the attached csv where column a in blank too! Php.ini http://pastie.org/4340845 mysql> select * from testBook1csv; +----+--------+ | id | field0 | +----+--------+ | 1 | NULL | | 2 | NULL | | 3 | NULL | | 4 | NULL | | 5 | NULL | | 6 | NULL | +----+--------+ 6 rows in set (0.00 sec) *************************output from your script********************** file upload example $_FILES array(1) { ["userfile"]=> array(5) { ["name"]=> string(13) "testBook1.csv" ["type"]=> string(24) "application/octet-stream" ["tmp_name"]=> string(14) "/tmp/phphf42G8" ["error"]=> int(0) ["size"]=> int(102) } } ls -l /tmp/phphf42G8 -rw------- 1 apache apache 102 Jul 27 00:17 /tmp/phphf42G8 $sql for create table string(110) "create table if not exists testBook1csv (id integer not null auto_increment primary key, field0 varchar(50))" $sql for load data string(142) "load data local infile '/tmp/phphf42G8' into table testBook1csv fields terminated by ',' optionally enclosed by '"' lines terminated by '\n'" Verify data contents Table testBook1csv string(28) "select * from testBook1csv" $sql= data array(2) { [0]=> string(1) "1" [1]=> NULL } array(2) { [0]=> string(1) "2" [1]=> NULL } array(2) { [0]=> string(1) "3" [1]=> NULL } array(2) { [0]=> string(1) "4" [1]=> NULL } array(2) { [0]=> string(1) "5" [1]=> NULL } array(2) { [0]=> string(1) "6" [1]=> NULL } -----Original Message----- From: tamouse mailing lists [mailto:tamouse.lists@gmail.com] Sent: Thursday, July 26, 2012 11:39 PM To: Brad Cc: jim.giner@albanyhandball.com; php-db@lists.php.net Subject: Re: [PHP-DB] Re: No data? With one change to the data file to make the indexing work correctly and read all the fields: to accommodate the first id auto_increment field, the first value in the csv line must be null: null.a,b,c,d,e null,f,g,h,i,j null,k,l,m,n,o And further, the field count should subsequently be one less in line 53 when creating the table: for ($i=0; $i < (count($fields)-1); $i++) { and that should do it. On Thu, Jul 26, 2012 at 10:20 PM, tamouse mailing lists <tamouse.lists@gmail.com> wrote: > Brad, do take a look at http://pastie.org/4340383 It does work.

Attachment: [application/vnd.ms-excel] testBook1.csv
« previous php.db (#48384) next »