Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

importing csv data that includes PASSWORDS 1

Status
Not open for further replies.

admoore

IS-IT--Management
May 17, 2002
224
US
I have a simple .csv file and wrote a little php file to import it into a MySQL table; however, one field needs to be password hashed and I am having trouble with the syntax to do this...

Here is what I tried:
Code:
     $result = mysql_query("LOAD DATA
                       INFILE  '/path/file.csv'
                       INTO TABLE users
                       FIELDS TERMINATED BY ','
                              ENCLOSED BY '\"'
                       (`user`, password(`password`))
                      ");
But, needless to say; I have issues...
Could somebody kindly help me out here with my syntax???

TIA,
-A
 
You can't import the file directly into the table; you would have to load the file into a temporary table and then into the real table:
[tt]
CREATE TEMPORARY TABLE t (u CHAR(20),p CHAR(20));

LOAD DATA INFILE '/path/file.csv'
INTO TABLE t
FIELDS TERMINATED BY ',' ENCLOSED BY '\"';

INSERT users (user,password)
SELECT u,PASSWORD(p) FROM t;

DROP TABLE t;
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top