Re: Importing data into MySql via PHP

From: Date: Sun, 26 Oct 2003 17:50:59 +0000
Subject: Re: Importing data into MySql via PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-167638@lists.php.net to get a copy of this message
Mark Roberts wrote: <snip>
I have a client that maintains a MySql database on a webserver. They want to import data into the database by uploading a Excel spreadsheet (most likely saved in a .csv format). I want to import the data directly into the data table via a php script. It appears that I should be using a LOAD DATA INFILE command or a MYSQLIMPORT command.
From reading documentation, it would appear the the LOAD DATA INFILE is the
way I would have to go as MYSQLIMPORT appears to be a command line only command. I could use some pointers from someone who has used this before....such as... 1. What is the default file format expected? (.csv?)
Doesn't really matter, as long as it's text/plain, and you know what the deliminter is (.csv usually is comma). It's been a long time since I used Excel, but I think you can specify the deliminter when exporting, and if that is still the case, I would go with a pipe (|). Commas are far to common in data to be used as a seperator IMHO.
2. Any quarks I would need to know about?
Not to my knowledge.
3. Etc...
No need to reinvent the wheel, check places like www.phpresourceindex.com to see if they already have a function / class to do what you need done.
Webmaster Services $29.50/mo
Do I get a cut of this? :) -- By-Tor.com It's all about the Rush http://www.by-tor.com

« previous php.general (#167638) next »