amir
11-29-2006, 06:51 AM
Hello,
I am trying to insert excel sheet data into mysql database. First, I convert that file into comma delimited CSV and then apply this code.
$link = mysql_connect("localhost", "user", "pass");
mysql_select_db("db");
$file = $_FILES['excel_file']['name'];
@copy($_FILES['excel_file']['tmp_name'], "files/$file");
$query = 'LOAD DATA INFILE /www/trisha/admin/"'.$file.'" INTO TABLE student_info FIELDS TERMINATED BY "," LINES TERMINATED BY "\\r\\n";';
mysql_query($query);
@unlink($file);
My purpose is
1; upload csv file
2; run load command and insert that file data into DB
2; remove that uploaded file
Please advise what I am doing mistake.
TIA!
I am trying to insert excel sheet data into mysql database. First, I convert that file into comma delimited CSV and then apply this code.
$link = mysql_connect("localhost", "user", "pass");
mysql_select_db("db");
$file = $_FILES['excel_file']['name'];
@copy($_FILES['excel_file']['tmp_name'], "files/$file");
$query = 'LOAD DATA INFILE /www/trisha/admin/"'.$file.'" INTO TABLE student_info FIELDS TERMINATED BY "," LINES TERMINATED BY "\\r\\n";';
mysql_query($query);
@unlink($file);
My purpose is
1; upload csv file
2; run load command and insert that file data into DB
2; remove that uploaded file
Please advise what I am doing mistake.
TIA!