Re: CSV Import Question

From: Date: Tue, 18 Nov 2003 05:51:08 +0000
Subject: Re: CSV Import Question
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-31606@lists.php.net to get a copy of this message
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 */

« previous php.db (#31606) next »