View Full Version : THE BEST way to upload info to the base?
Hello,
I need to upload a lot of info from my PC to mysql databse every day. And I need to write a program (I have experience with C++, PHP, MySQL ), that will do it.
What is the best way to upload information? Maybe .CSV? How to do it from local PC? Not using phpMyAdmin. It will be ok if upload some file to the web, and then click ONE button. It should be simple to use for everyone.
Please help!
Regards, Andrei.
mitchind
10-2-05, 06:37 PM
You don't say what type of database you have on the PC side - or is it just a flat file that you want to import into one MySQL table? Or can you export it as SQL commands?
How big is the file?
In my opinion, the simplest import is a mysqlimport command on a tab-delimited file. This works best when the data order can match the order of the table's fields.
If you want one-click - then do you plan on hardcoding all of the MySQL database info into your script?
You can do it with a php script - maybe combining with cgi for big file uploads - unless you're going to assume the file is going to get there some other manual way - like ftp.
RTH10260
10-3-05, 01:38 AM
What is the best way to upload information? Maybe .CSV? How to do it from local PC? Not using phpMyAdmin. It will be ok if upload some file to the web, and then click ONE button. It should be simple to use for everyone.On the PC side create a CSV file.
On the webserver side create a form with a FILE button. The user must locate the CSV file and click submit. If you wish to automate this a bit more, and the file has always the same name and location on the PC filesystem, insert the path as default value. If you don't want that the user needs to click the submit button, use the onload event for the page to trigger such a predefined upload. The form uses ACTION= to submit to the following script.
On the webserver, create a script (php) that will take the file just uploaded with the form. Use the php commands to read a csv formatted file and split the line into the variables. Use a simple sql insert command to put the data into the table.
Depending on the size of the uploaded file, you may have to split the uploading and the database inserts into two separate scripts.
vBulletin v3.6.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.