I just can\'t seem to get this query right. Basically I\'m taking a csv from a form and trying to load it into the database. I took the majority of the query from phpmyadmin. i
Not sure why are you using that long-ass url for action instead of index.php or just ''? Also I think you need to specify ENCTYPE="multipart/form-data" since it's an upload form for a file. Not sure how to just just insert the file, I think you need to get contents of the file, then explode it and do insert
$pfile = $_FILES['white']['name'];
$ptmpName = $_FILES['white']['tmp_name'];
$fileSize = $_FILES['white']['size'];
$fileType = $_FILES['white']['type'];
$fp = fopen($ptmpName, 'r');
$content = fread($fp, $fileSize);
$content = str_replace("\r\n", "\r", $content);
$Data_Lines = explode("\r",$content);
for ($n = 0; $n < (count($Data_Lines)-1);$n++){
$line = addslashes($Data_Lines[$n]);
$Value = explode(",",$line);
...//The you run insert statements for $Value[1], $Value[2]...///
}
Or you can use fgetcsv - check this article: http://www.programmingfacts.com/import-csvexcel-data-mysql-database/
You need to escape the slash for the lines terminated clause, otherwise you just added a newline to your query.
LINES TERMINATED BY '\\n'
Mysql will just get \n
, but PHP tries to interpret those so you have to escape them.
You may have other issues, but you haven't told us what happens.