Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




File Import Script


I currently have an uploader that runs on my site that allows the user to upload a .csv file to the server, it then prompts them to match up each field in the file with the corresponding field in the database table.  It works pretty good, but a little bit clunky and with the way I currently have it setup, it will only insert into the database, I can't update. 

Does anyone know of a good .csv uploader that will let the customer match up the columns in the .csv file with the fields in the database as well as do updates and inserts with records in the database? 




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Do Import .sql File To A Db In Php
how would i would do something like this only with php

mysql>mysql -u user -ppassword database < file.sql

Import Sql File Please Help Me!
i have just installed mysql on osx. i think its running ok. i have tried to import my dump file from the remote server to my local mysql. but no luck! please help me

tying to use -u -umyusername -pmypassword < path to sql file
in the mysql terminal in shell on osx

but its not working. to be honest i dont have a clue when it comes to using the terminal. i cant seem to be able to even create a new databse.

i have my .sql file and i want to run my local mysql the same as the production mysql online for testing.

also my database is called mydomain_com_-_mydatabase

not sure why i have _-_ but online all my php works fine.

i dont want to have to use two connect scripts, can i use the same connect script to connect local and remotely.

some one please help me to get mysql up and running localy!

Import Data From File.sql
i have already backup my database into a file named backup.sql from phpmyadmin..
now i want to make an interface using php to restore it like phpmyadmin too, does anybody know how? when i click submit then file backup.sql will be restored in database, Code:

Import CSV File Into Database Table
Are there any programs like phpmyadmin, that allow you to import CSV files without first converting them into mysql statements? mysql front?

I've created the table and fields, and it should be easy enough to import the data into its respective columns.

Import Data From Text File?
I'm not sure how to do this, can anyone steer me in the right direction?

I have a DB table called 'vehicles'

It has three columns:
ID ¦ vehicle_type ¦ vehicle_make

I have a text file containing a list of the vehicle types and makes. Example:

Austin Healey - 3000, Sprite
Austin Passenger - 1800, Allegro, Ital, Maxi, Mini
Bentley - Corniche, Mulsanne, T Series

How would I import this into my database?

Trying To Import A .csv File With Usernames And Passwords In Sha-1
can someone give me some advice on how to import a csv file and make the passwords store in a hash form such as md5 or sha-1. It would be to much to code the INSERT VALUES....way. I am trying to find an easier way. Is there a feature in one of these free gui versions of mySQL that will do this?

Import The Excel File Into Sybase Database
want's to know how to import the excel file into Sybase database & do some manupulation within the database & save the data back to excel file through Visual Basic.

Import Excel File Into MySQL Database
I am relatively new in this field, and one of my first challenge is the following :

Importing an Excel file, containings URL, into a MySQL database.

It must be the simplest process possible for the end user, avoiding as far as
possible all steps of converting and/or transforming files.
Of course, we want to preserve the identity of the URL.

Import Excel File To Mysql Database
i want to import excel file into mysql database .

Php Import Xls Into Mysql
<?php
$target_path = "/home/vol1/example.us/a/ayush/www/virtual/closing/";
$target_path = $target_path . basename( $_FILES['file']['name']);
if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['file']['name']). " has been uploaded";

include ('mysql.php');
require_once 'reader.php'
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('CP1251');
$data->read('closing/closing.xls');
error_reporting(E_ALL ^ E_NOTICE);

for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++)
{
$closing = $data->sheets[0]['cells'][$i][2];
$sql = "UPDATE listedcomp SET closing = '$closing'";
if (mysql_query($sql)) {
echo "Done";
} else {
mysql_error();
}}

} else{
echo "There was an error". $_FILES['file']['error']." uploading the file, please try again!";
}?>

PLEASE HELP! This code isn't importing the data properly....when i see the closing column...all the values are set to 1000, idunno why?

The column is set to interger type......

Import Dbf To PostgreSQL
Anyone can help me...i don't know how to import database from dbf to
postgreSQL......

Import And Export
Anyone could give me some tips about coding an import and export php script
with mysql ?

Import A Database
I need help importing a database using MySQL and PHP. I have a file that is tab separated, and I need to import it into a MySQL database.

Directory Import?
I'm developing an interface where I want the user, after logging in, to be able to view files such as images, pdf's, quicktimes.  First off, can they view these files within the interface or do they have to open the PDF's and Quicktimes with another piece of software?

Also, because the files will be changing every few hours, can I set this up so that they load from a folder rather than from a database.  I would need to be updating the database 24 hours a day in order to keep up so it would be much easier for me if they loaded from the folder.

Automating A Datafeed Import
I am integrating an external datafeed that is changing daily. How do I make my MySQL database pull this fresh data daily and update all my pages with new content?

Import Geographical Data
I'm writing an internet marketing application in php and I need to
import inside a mysql db all data about countries, district or
provinces, towns or cities, villages or other places of interest in
the world.

Can you suggest me where I can import or grab or simply buy these kind
of geographical data?

PHPMyADmin Error CSV Import
I recently upgraded to XP, Latest Mysql and Latest PHP. I run IIS local and used to be able to imprt CSV files to all my external databases as well as my local. Now I can only do it on my local. When I try to import to an external i get the following error using PHPMYADMIN SQL-query :

LOAD DATA INFILE 'C:PHPuploadtempphp24.tmp' INTO TABLE `developers` FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '' LINES TERMINATED BY '
'
MySQL said: File 'C:PHPuploadtempphp24.tmp' not found (Errcode: 2) Now I thought it was permissions but they are wide open and I have the ini file set up correctly i think for windows - i have tried all combos of slashes so not that:

;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

file_uploads = On
upload_tmp_dir = C:PHPuploadtemp
upload_max_filesize = 2M

Import SQL7 DB Into MySql?
Can I import a a SQL7 table into a MySql?

Web Form Using Php To Import Into Access Db
I need to make a web form in php, that sends me the results by mail, ok, that is the easy part, I know how to do it, the thing I don't know, is that I need that the results get formated to import them into Access, as a delimited text with | delimiter.

I already have the web form, but the results that send by mail are not formatted to import them into Access, here is an example what I need, to ilustrate my question better:
Web form: (What the user see and must fill) Code:

Import Access Into MySQL
Is there a way to import MS Access into MySQL? Maybe create a CSV or
something. If so, what would be the SQL to do this?

How To Import Contacts From Hotmail
Please give me the solution for to import the contacts from Hotmail. I
searched for this criteria in google. It gives some demo site which
provides the actual process. Anyone got the script for import contact
from hotmail....

Mass SQL Import (singles Are Ok?)
i have some code that imports alot of data into the MySQL database,

Now this is fine when i use the INSERT INTO one record at a time.. but if i do 2 records ie

INSERT INTO `PB2` (`field1`,`field2`) VALUES ('111' ,'222');
INSERT INTO `PB2` (`field1`,`field2`, `field3`) VALUES ('333' ,'444', '555');

in which case i get the error

QuoteYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; INSERT INTO `PB2` (`field1`,`field2on line 1

so it would seam the ; is causing the problem.. but even when i do them one by one it has the ;, AND if i copy the SQL statement that is echoed with the error and run it in PMA (phpMyAdmin) it runs without error!..

the only thing i can think of is a limit set by the host.. ?

How To Import Images Stored Into A Remote PC
I need to put into a page of my site a window to "Sfoglia" into the PC of the visitor and to import to my site/server images.gif stored into his PC.

Import/export Problem With CSV/PHP/MySQL
I need to design an import/export system. Data comes from a filemaker
pro DB in a big CSV file. Some alterations are made on the data as it is
imported into my mysql table. Data is something like :id,text1html,
text1raw,... .

Problems :
1. Texts can contain html tags, including entities (&quot; etc), so
using only the '' as separator does not work.
2. Some line are so long that is appears php breaks them down, so I lose
data reading the file.

For 1, I've come across fgetcsv() in recent posts. Works fine for now.

For 2, I can't seem to find a solution. I've tried to detect "broken"
lines and stick them back together but no effect...

Another problem arises when I try to export the data back into CSV, as
it is suposed to be used in Excel. The CR/LF that are in the text are
logically interpreted as new rows in Excel. How can I get around this ?
Is there a special "new line" character that excel would not interpret
as new row ? Should I try another file format ?

Check A Directory For Files To Import
I want our company employees to be able to update our website with special formated emails. My IT guy has made a perl script to parse the email to a text file formatted the way I want.

I want him to dump the txt file into a directory, that is being watched. When a new file is put there, I want something to pass the name onto my PHP script, so it can run, and import the file into mySQL. My PHP script works if I tell it what the name of the file is, but I have to execute the script myself. I am not sure if I can use PHP to monitor the folder for new files, or if I need to use a crontab, or what?

PHP Import/export Language Packages?
I have a small PHP script that is multilingual and all the phrases are stored in the database. It currently can export the phrases for a specific language package and it can also import the exported data. So it allows the usage of other language packages in the future.

It works great with the default language package I have setup, which is English; however I am having problems with other languages such as Polish, Greek, Russian etc... When I export the data and then try to import the data using my script all the special characters turn into question marks.

Since the exported data is in a flat PHP file I use PHP fwrite to write to the file. I tried to use PHP's utf8_encode, however that did not do much help. I also tested to change the collation of the database, which also did not help.

So I am rather lost as to how scripts like vBulletin can export language packages and then import it, while dealing with character issues.

Import Request Variables Command
I currently use flash to get the info and send it to php and mail it out. Now for some reason my information is not getting posted, I know someone told me was I needed to put Import Request Variables command since my server has Register Globals OFF. Here is my script. How do i add it on this. Code:

Import Data From Access Database To MYSQL
I have some data in access database. I wish to import it (keeping the same structure) in MySQL.

Also I want to know what will be procedure for importing data from databases like Oracle, Sybase, Informix etc.

How Can I Increase The Import Maximum Size For MySql
I have a requirement for importing a sql file in my local databse.I
have exported the file from the client database.That file is more than
50mb.I want to import this sql file into my local database.My Maximum
import file size showin as 8mb.I tried to change by editing the ini
file.But still it showing the same.I am using phpMyAdmin.Please tell me
the procedure to change the Maximum File Size for Importing sql file.

To Get A File Name, File Size, File Type...?
Is there a way to get information about a file BEFORE it is submitted to the server?
I am trying to make a upload progress bar from scratch WITHOUT THE PRON.C PHP FIX!!!
I found the file being uploaded in my NET://WINN01910//TEMP folder and I can outputs its file size in a popup with a one second refrehs, but this makes it so the USER needs to know the full file size to know if its anywehre near done. 

Is there a way to get the filesize from the clients side?  Possibly javascript that uses ajax to submit the values to the server before the file is sent but when it is selected?? Is there an easier way to do this and/or do you have any ajax example code of how it might work?

I also have another problem, Althoguh i can echo the filesize of what is recieved so far, I am just glob()ing the temp folder for: "php*.tmp" but is there a way to tell the tmp file so they don't see everyone's uploads?

FIle Uploads: Empty _POST And _FILES Arrays When File Too Large
Uploading of files.. AFAIU from the manual, if a file is larger than the
size defined in the form or larger than upload_max_filesize in php.ini,
that _FILES['file']['error'] should hold an INT error code.

The file upload system is working fine if the file is smaller than the
defined size, but if it's larger, then both the _POST and _FILES arrays
are completely empty:

array(0) {
}

I can obviously check to see if $_FILES is set and contains elements,
but I was hoping for more specific error handling (reason as to why the
upload failed).

Has anyone else encountered this? Any info welcomed =)

Checking File Existence Through A List Of File Locations Gathered From An Array
I've been trying to wrote a code to check the existence of some files gathered from a field in mySql database.

And I am kind a stuck at a point where I get the file locations from the database but when it passes those locations to file exist it keeps telling me the file does not exist.

Only first file exists the other 2 file does not exist to test if the code was working or not. Code:

Email With File Attachements - How To Upload File To Server From Browser?
I have a PHP script that sends an email with attachment and works great when
provided the path to the file to send.

However this file needs to be on the same server as the script.

I want to develop a webpage where people can send attachments that are
stored on their local PC.

I know I can use the <input type="file" > HTML to generate a file box that
allows the user to navigate to a file on their PC and product a file path,
but how do I then upload this file onto file server to email out with my PHP
email script?

Is there an easy way to do this?

Or can I approach this problem from a completely different angle.

Creating Link To File Or Temp File For User Download
I am designing a document management system (DMS). The files are stored
in a directory on the webserver. The filenames for the documents are
stored in a MySQL database. The DMS will track revisions from the
initial version through the updates. We must have strict permissions
set so only authorized personnel can access some documents. All of the
documents when uploaded are given totally random names such as
"114723fb5422c6bd5ed18f6.doc". Is there a way, without the webserver
creating a new file name "document_specs_ver2.doc" to have the file
download named "document_specs_ver2.doc".

If I must physically create a new file, how do I know when the
webserver would be allowed to delete it? Notes: The files will be in
several different file formats, not just "doc".

Header Function, File Download, Temp File Disappears
I have the following headers:

if (preg_match("/compatible; MSIE/i", "$browser_type")){
header("Content-Tranfer-Encoding: binary");
header("Content-type: ".$assoc["type"]."");
header("Content-Disposition: attachment; filename="".$assoc["name"].""");}
echo $assoc["file"];

which starts the download of an mp3 file in one particular case. If you do not save target as and just select 'open' the temp file is zero bytes even though the download process took a while and showd how much progress you were making. So something is happening to the temp file.

Warning: File(): URL File-access Is Disabled In The Server Configuration
Does any one know how to work around this error on a web site?

Warning: file(): URL file-access is disabled in the server configuration ...

Load .txt File From Computer And Save The File In Www/folder Director
anyone know how to add the .txt file from computer into the localhost www/Myfolder directory.

Download File And Delete File From Server With One Button Click
I want the user to be able to download a CSV file and delete the file from the server all with the click of a button.  Currently, in firefox, it will just display the CSV and not delete it. In IE, it will download the CSV and not delete it. Code:

Open File, Put First 5 Lines Into A Variable, Close File...
1) I want to open a file on my server.
2) I want to read only the first 5 lines.
3) Put the first five lines into a variable.
4) Close the file.
5) Display the contents of the variable.

I know how to use the fopen() but I have big problems just trying to read the first 5 lines only? I tried many things. I downloaded some search scripts which displayed the <meta> tag only from html pages...

What is this guy doing?

Well I have a big site and content is added and changed everyday. I have a dynamic page that reads a directory for files and then puts a link (well it includes the file for reading on my php page). That works great! MY PROBLEM is that I want not only a link but a small description below it (basically the first five lines on the file)...

See so far:
Quote: if (isset ($content)) {
include ("files/$content.html");
echo "<p><A HREF="read.php"><b>Back to index</b></A>";
} else {
echo "<b>Opening directory, reading files, and listing them as a link</b><p>";
$handle = opendir('./files');
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo eregi_replace (".html", "", "<A HREF="read.php?content=$file">$file</a><p>");
}
}
closedir($handle);
}

Open .php File With PHP Designer 2007 By Clicking The File In XP
In windows XP, I want to be able to click on a .php file and have it
opened in PHP Designer 2007,
Or right-click on it and have an "edit" menu option presented to me.
I know how to tweak the registry to do this in general, but what would
the command line look like in this specific case ?
PHP Designer does not do this automatically. It is as if the program
does not allow commandline options.
It only opens with the last file used or a menu of recently opened
files.

PHP File Upload Unexpected Error - File Too Large?
I have a short basic script to upload files. It works fine with small files,
but with longer files it gets stuck.

Here's the fragment, the input file is loaded in "$file" from an HTML form
as usual.

....
$img_str = fread(fopen($file, "r"), filesize($file));
$data = addslashes($img_str);
// --------------------- up to here the execution is correct and fast (<1
second)

$sql="INSERT INTO $table (".
" file_name,".
" file_type,".
" file_size,".
" bin_data)".
" VALUES (".
" '$file_name',".
" '$file_type',".
" '$file_size',".
" '$data')";
// --------------------- it gets stuck
here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
mysql_query($sql) or die ("SQL error ..$sql");

I have already set the php.ini variables as follows:
memory_limit = 16M
upload_max_filesize = 6M

I also checked the execution time to max_execution_time = 300 (even though I
don't believe it should be necessary).
The server is a P4 1.8 GHz, 256MB RAM

Displaying File Path In File Input Field
i have file input field in a form like this:
<input name="isbn" type="text" size="25" value="<?php echo
$_POST['isbn'] ?>" />
<input name="image" type="file" size="25" value="<?php echo
$_FILES['image']['name'] ?>" />

when i press "submit" button, the same page gets loaded... if my
$_POST['isbn'] is empty, i want to have the file path on "file input
field" to redisplay on that same field... it's possible in text input
field but i don't know of a way to do it in file input fields...

PHP/IIS: File Read/Write OK, File Unlink Denied
I've got PHP running fine on IIS (OS: Server 2003, SP1; IIS: 6.0; PHP:
4.3.11).

In PHP, the user uploads a file, which is then processed and the
contents are inserted into a new file, created in PHP, onto the server.

This bit works fine, the new file created by PHP is correctly stored.

Later, once the user confirms the upload and PHP inserts the contents
of the file into the DB, the code tries to remove the file created in
PHP moments earlier, via the unlink() function.

What I see on screen is the following: Permission denied

I have made sure that the permissions for the Internet account that
created (and is trying to delete) the file have full permissions over
this particular folder and the files within it. But the user must have
permission anyway, because they are able to create this file in the
first place.

I've looked at the permissions for the file in PHP, which read: 0666.
So everthing *appears* ok to me; I can't see where the permission issue
is coming from.

Mkdir() How Do I Automatically Make A Index File And A Css File
using mkdir() how do i automatically make a index file and a css file. what i really mean is once the directory has been made how do i make it so i have a index and css file there, its just because im making a forum hosting service and i need all the files automatically set up in the directory. how can i do this?

How Can I Find Out Parent (including) File Of Included File?
How can i find out parent (including) file of included file?
Lets imagine that we want to for example auto_prepend file to each file on our server that would write out the name of file  its being executed. I know, i can use PHP_SELF but what if i want to write name of file which is already included?

I have a web page and i want on it show its name even if it was included, but not the included page itself is showing name but auto_prepend file to each php file, its duty of this auto_prepend_file to write it out i dont want myself to echo it on each page? do you feel me?

Exporting DB Results (or Flat File) To An Excel File
I have two scripts, neither of which have been written, that will need to collect user information. They will either write to a flat file or to a MySQL DB, and I need a way for an administrator to grab an Excel file based on this data.

First, no more than 100 people are expected to sign up, so flat file is certainly viable. Do you recommend I use DB or flat file?

Second, based on your recommendation, how should I go about exporting the user data to an Excel file? There will be about ten form fields per registration to give you an idea.

Php File To Call On A File In A Password Protected Directory
Does anyone know is I can have php file calling on a file in a password protected directory (through basic authentication)?

File Upload Script - Testing For Existence Of File
i'm having a strange problem when processing some form data. I just want to validate that required fields have been populated, then, if an image has been uploaded, i want to ensure that a description of the image has been provided (for alt tag purposes) before processing the data.

For some reason, when a file hasn't been attached, my script interprets it otherwise and prompts the user for the alt tag. I've not come across this problem before, there's a good chance i've done something idiotic but i just can't see it Code:

Write To File Sometimes Deletes EVERYTHING, Leaving Empty File
I've used PHP to save raw data from Flash to an XML in the past. Load the XML into flash, update a couple variables, then send it to PHP to completely overwrite the old .xml file. This works great most of time, but sometimes after a few days, I'll check the .xml and it will be empty (0 bytes).

Not sure if this is caused by a user who aborted during the writing process, or simultaneous connections, etc. Been thinking about doing a backup every day using CRON, but that's a mission and I'd like for it not to happen full stop. Any suggestions?


Copyright © 2005-08 www.BigResource.com, All rights reserved