Re: [PHP-DB] CSV Import Question
Hi there, Oh I know the , (Or $Delim) isn't the problem, I think your previous email may be the answer so i'll take a good look at that once i've eaten and if it works you're the best (Heck even if it doesn't you're all the best on this list ;-) Chris Try it with just "," instead of "$delim". If it works, then you know that is your problem. Chris Payne <[EMAIL PROTECTED]> wrote: Hi there, Yes, in the form itself there is an input field where you specify the character for import, as default it is set to , but you can change it to any. Chris > On Tuesday 18 November 2003 13:07, Chris Payne wrote: > > > > > any ideas? Here's the code: > > > > > > > > $row = 1; > > > > $handle = fopen ("$userfile","r"); > > > > while ($data = fgetcsv ($handle, 250, "$delim")) { > > > > $num = count ($data); > > > > $row++; > > > > for ($c=0; $c < $num; $c++) { > > > > > > > > mysql_query ("INSERT INTO emaillist (EMail,name) > > > > VALUES ('$data[$c]','$data[$c]') > > > > > > > > When I import, it puts all data in the EMail field, even the name > > > > field. > > What exactly do you mean by "puts all data in the EMail field"? Does > print_r($data) look OK? And you do realise that in your SQL statement you're > inserting the same value for both EMail and name? > > > > What's $delim? > > > > Sorry, delim is from the form you use to select the CSV file, as you can > > select the char as the seperator (I have set the default to a COMMA > > though). > > By that you do mean: > > $delim = ','; > > and not > > $delim = COMMA; > > ? > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.biz > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > -- > Search the list archives before you post > http://marc.theaimsgroup.com/?l=php-db > -- > /* > Pilfering Treasury property is paticularly dangerous: big thieves are > ruthless in punishing little thieves. > -- Diogenes > */ > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard
Re: [PHP-DB] CSV Import Question
Hi there, Yes, in the form itself there is an input field where you specify the character for import, as default it is set to , but you can change it to any. Chris > On Tuesday 18 November 2003 13:07, Chris Payne wrote: > > > > > any ideas? Here's the code: > > > > > > > > $row = 1; > > > > $handle = fopen ("$userfile","r"); > > > > while ($data = fgetcsv ($handle, 250, "$delim")) { > > > > $num = count ($data); > > > > $row++; > > > > for ($c=0; $c < $num; $c++) { > > > > > > > > mysql_query ("INSERT INTO emaillist (EMail,name) > > > > VALUES ('$data[$c]','$data[$c]') > > > > > > > > When I import, it puts all data in the EMail field, even the name > > > > field. > > What exactly do you mean by "puts all data in the EMail field"? Does > print_r($data) look OK? And you do realise that in your SQL statement you're > inserting the same value for both EMail and name? > > > > What's $delim? > > > > Sorry, delim is from the form you use to select the CSV file, as you can > > select the char as the seperator (I have set the default to a COMMA > > though). > > By that you do mean: > > $delim = ','; > > and not > > $delim = COMMA; > > ? > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.biz > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > -- > Search the list archives before you post > http://marc.theaimsgroup.com/?l=php-db > -- > /* > Pilfering Treasury property is paticularly dangerous: big thieves are > ruthless in punishing little thieves. > -- Diogenes > */ > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] CSV Import Question
On Tuesday 18 November 2003 13:07, Chris Payne wrote: > > > any ideas? Here's the code: > > > > > > $row = 1; > > > $handle = fopen ("$userfile","r"); > > > while ($data = fgetcsv ($handle, 250, "$delim")) { > > > $num = count ($data); > > > $row++; > > > for ($c=0; $c < $num; $c++) { > > > > > > mysql_query ("INSERT INTO emaillist (EMail,name) > > > VALUES ('$data[$c]','$data[$c]') > > > > > > When I import, it puts all data in the EMail field, even the name > > > field. What exactly do you mean by "puts all data in the EMail field"? Does print_r($data) look OK? And you do realise that in your SQL statement you're inserting the same value for both EMail and name? > > What's $delim? > > Sorry, delim is from the form you use to select the CSV file, as you can > select the char as the seperator (I have set the default to a COMMA > though). By that you do mean: $delim = ','; and not $delim = COMMA; ? -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* Pilfering Treasury property is paticularly dangerous: big thieves are ruthless in punishing little thieves. -- Diogenes */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] CSV Import Question
Hi there, > On Tuesday 18 November 2003 12:34, Chris Payne wrote: > > > I have a 2 Column CSV file, and i'm trying to import it into the DB via a > > form, I have it importing fine with the first field (Called EMail) but I > > cannot get it to import the second column correctly (Called name). I know > > it's going to be something so obvious i'll pass out, but does anyone have > > any ideas? Here's the code: > > > > $row = 1; > > $handle = fopen ("$userfile","r"); > > while ($data = fgetcsv ($handle, 250, "$delim")) { > > $num = count ($data); > > $row++; > > for ($c=0; $c < $num; $c++) { > > > > mysql_query ("INSERT INTO emaillist (EMail,name) > > VALUES ('$data[$c]','$data[$c]') > > > > When I import, it puts all data in the EMail field, even the name field. > > What's $delim? Sorry, delim is from the form you use to select the CSV file, as you can select the char as the seperator (I have set the default to a COMMA though). Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] CSV Import Question
On Tuesday 18 November 2003 12:34, Chris Payne wrote: > I have a 2 Column CSV file, and i'm trying to import it into the DB via a > form, I have it importing fine with the first field (Called EMail) but I > cannot get it to import the second column correctly (Called name). I know > it's going to be something so obvious i'll pass out, but does anyone have > any ideas? Here's the code: > > $row = 1; > $handle = fopen ("$userfile","r"); > while ($data = fgetcsv ($handle, 250, "$delim")) { > $num = count ($data); > $row++; > for ($c=0; $c < $num; $c++) { > > mysql_query ("INSERT INTO emaillist (EMail,name) > VALUES ('$data[$c]','$data[$c]') > > When I import, it puts all data in the EMail field, even the name field. What's $delim? -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* Business will be either better or worse. -- Calvin Coolidge */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php