Forum Moderators: open
idFirstNameDateOfBirthCellPhoneAge
1PAT 9/13/1947504621146859
2EDNA 4/24/1976 30
3CATINA 9/3/1972 504975773034
Number of records(queries) to skip from start = 0
CSV using LOAD DATA
Fields terminated by \t
Fields enclosed by "
Fields escaped by \
Lines terminated by auto
Column names id,FirstName,DateOfBirth,CellPhone, Age
---------------------------------------------------------------
LOAD DATA INFILE '/tmp/phpUyInJ6' INTO TABLE `dcn` FIELDS TERMINATED BY '\t' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\r\n'(
`DCN_id` , `FirstName` , `DateOfBirth` , `CellPhone` , `Age` )
MySQL said:
#1045 - Access denied for user 'fasttaxs'@'localhost' (using password: YES)
------------------------------------------------------------------
Why do I get this error?
Any help is appreciated.
Thankyou
I am trying to use below script.
But it shows me error
-
insert into DCN values ('1,PAT,9/13/1947,5046211468,59,,7.23243E+11,No,PURDY ')
Column count doesn't match value count at row 1
It does not separate the columns using '\t'
What is wrong here.
-----------------------------------------------------------
$fcontents = file ('returningClients.csv');
# expects the csv file to be in the same dir as this script
for($i=0; $i<sizeof($fcontents); $i++) {
$line = trim($fcontents[$i], '\t');
$arr = explode("\t", $line);
#if your data is comma separated
# instead of tab separated,
# change the '\t' above to ','
$sql = "insert into DCN values ('".
implode("','", $arr) ."')";
mysql_query($sql);
echo $sql ."<br>\n";
if(mysql_error()) {
echo mysql_error() ."<br>\n";
}
}
No that is not what I want.
I wanted
insert into DCN values
(1,'PAT',9/13/1947,5046211468,59,,7.23243E+11,'No','PURDY')
When I change '/t' to ',' it accepts, but in the below way.
insert into DCN values ('1','PAT','5046211468','59','','7.23243E+11','No','PURDY ')
Data truncated for column 'DCN' at row 1
column DCN is BigINT(20)
Why wouldnt it accept it?
maybe take a look at this for syntax
[dev.mysql.com...]
I think It will if I change it to varchar
insert into DCN values ('1','PAT','5046211468','59','','7.23243E+11','No','PURDY ')
Data truncated for column 'DCNNO' at row 1
The value for DCNNO = 723243040617.
But in CSV file, it displays like - 7.23243E+11.
When I manually insert the above row, it shows no erros.
insert into DCN (dcn_id, FirstName, CellPhone, Age, emailAddress, DCNNO,IRAL, Lastname) values ('1','PAT','5046211468','59','',723243040617,'No','PURDY
');