I'm trying to upload this csv file to mysql on my hosting.
The csv is built by two columns:
alias, id
and than each row contains the data.
Here is an image

But the mysql rejects me. why is that?
I'm trying to upload this csv file to mysql on my hosting.
The csv is built by two columns:
alias, id
and than each row contains the data.
Here is an image

But the mysql rejects me. why is that?
Create a table "test_table " with two fields "alias" and "id", then execute this command:
LOAD DATA LOCAL INFILE '/importfile.csv'
INTO TABLE test_table
IGNORE 1 LINES
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
(alias, id);
if your are using phpMyAdmin use the import option of phpMyAdmin. Choose CSV file format
$file = 'path/to.csv';
$lines = file($file);
$firstLine = $lines[0];
foreach ($lines as $line_num => $line) {
if($line_num==0) { continue; } //escape the header column
$arr = explode(",",$line);
$column1= $arr[0];
$column2= $arr[1];
echo $column1.$column2."<br />";
//put the mysql insert statement here
}