I just can't get this request correctly. Basically, I take csv from the form and try to load it into the database. I took most of the requests from phpmyadmin. Should I use a temporary file correctly? here it is...
<form name = "price_chart" method="post" action="index.php?option=<?php echo $option ?>&task=complete" enctype="multipart/form-data">
<label>File: </label>
<input type="file" name="white" id="white"/><br />
<input type="hidden" value="TEST" name = "test" />
<input type="submit" name = "upload" value="Upload File" />
</form>
<?php
}
function complete($option){
$pfile = $_FILES['white']['name'];
$ptmpName = $_FILES['white']['tmp_name'];
$test = $_POST['test'];
$result = mysql_query("LOAD DATA LOCAL INFILE '$ptmpName' REPLACE INTO TABLE 'jos_rates_table' FIELDS TERMINATED BY ',' ENCLOSED BY ' ' ESCAPED BY '\\' LINES TERMINATED BY '\n'('country' , 'rate')")or die ('Error: '.mysql_error ());
while ($row = mysql_fetch_array($result)) {
}
$num_rows = mysql_num_rows($result);
echo $num_rows;
}
UPDATE: here is the error message
You have an error in the SQL syntax; check the manual that matches your MySQL server version for the correct syntax to use next to '' jos_rates_table 'FIELDS TERMINATED BY', 'ENCLOSED BY' 'ESCAPED BY' \ 'LINES' on line 1
source
share