--- Marian Briones <[EMAIL PROTECTED]> wrote:
> My old system used a perl script to read a | delimited file and pour
> the content into a database.
>
> Now, I made a system that uploads the file and pours it in. I am
> trying to now modify it further to make it NOT upload a file, but take
> the file contents from a text area and each line is one record in the
> table
>
> ...
>
> Here's the code I grabbed - it refers to sizeof the export which used
> to be a file, but now it's lines of text in a text area. I'm sure
> that's where I'm going wrong but don't know how to handle it:
>
> ...
>
> So what I get is one big whopping insert with ALL of the lines in one
> line of insertion which, of course, gives me the 'column count' error,
> and if MySQL could laugh, it probably would be rolling on the floor.
>
> So, how can I have my data I paste into the textarea not only get
> everything filtered out but get formatted properly to go into a db
> table? I've been testing my output by having it return to the screen.
>
> Thanks
>
> Marian
Your textarea tag supplies the content as one big string variable -- as it was
intended to do. To divide the value into multiple lines, you will want to
split() based on the newline and/or carriage return character. Fortunately,
split() will use a regex so I would suggest:
$array = split("[\r\n]+", $textarea);
use something like this to diagnose and make sure your content is stored as
expected:
printf("<pre>\n%s</pre>\n", print_r($array, true));
James
_____
James D. Keeline
http://www.Keeline.com http://www.Keeline.com/articles
http://Stratemeyer.org http://www.Keeline.com/TSCollection
http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc.
Fall Semester Begins Sep 7 -- New Classes Start Every Few Weeks.
Spring Semester Begins in late January. Two new class topics.
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
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/