--- In [email protected], "Marian Briones" <[EMAIL PROTECTED]> wrote:
>
> Hi James
>
> The code **looks** like it should work, I modified it as I need to so
> it would address my db but it is giving me an empty string :
>
> Warning: split(): REG_EMPTY
>
> and the line number.
>
> I have an absolute path noted where to get the data file and the data
> file is there. It's also giving me header woes.
>
> My code looks like this (with private things removed):
>
> copy($export,
> "/home/finis/public_html/admintools/up/finisdata.txt");
>
>
>
> $input_file =
> file("/home/users/public_html/admintools/up/userdata.txt");
> foreach($input_file as $line)
> {
> list($email,$first,$last) = split("|",$line);
> $q = "INSERT INTO $name SET email='$email', first='$first',
> last='$last'";
> // mysql_query($q, $db) or die("<BR>Shoot: $q<hr>" .
> mysql_error());
> mysql_query($q) or die("<BR>Shoot: $q<hr>" . mysql_error());
>
> header ("Location:http://return
> page/admintools/managemailinglist.php?listname=$name");
> }
>
> I'm not sure why it is not getting the data.
>
> ????
> --- In [email protected], James Keeline <keeline@> wrote:
> >
> > --- Marian Briones <mjbriones@> wrote:
> >
> > > I want to be able to take a flat file that looks like this:
> > >
> > > mbriones@|Marian|Briones
> > > bobsmith@|Bob|Smith
> > > janedoe@|Jane|Doe
> > > (etc)
> > >
> > > The table has more than 3 fields, so I'd want to process the
flat file
> > > and then do an INSERT into mailinglist SET field=$value for each
line.
> > >
> > > Does someone have a nice way for me to do this? The flat file
will be
> > > uploaded to the server via a form (copy) and then be processed.
> > >
> > > I've googled and can't find what I need.
> > >
> > > Thank you in advance,
> > > Marian
> >
> > Basically you want to take each line and divide it up based on the
> "|" character.
> >
> > $db = mysql_connect("localhost","dbuser","dbpwd");
> > mysql_select_db("dbname");
> > $input_file = file("filename.txt"); // puts each line into an array
> element
> > foreach($input_file as $line) // loop through file array
> > {
> > list($email,$first,$last) = split("|",$line); // chop up line
> > $q = "INSERT INTO tablename SET email='$email', first='$first',
> last='$last'";
> > mysql_query($q, $db) or die("$q<hr>" . mysql_error());
> > }
> >
> > This code is untested and you will have to modify it to meet your
> needs and situation.
> >
> > James
> >
>
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
YAHOO! GROUPS LINKS
- Visit your group "php-list" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
