Donovan Posted April 22, 2008 Share Posted April 22, 2008 $fileName = basename($_FILES['file_source']['name']); move_uploaded_file($_FILES['file_source']['tmp_name'], $uploadFolder.$fileName); $Studentfile = "$uploadFolder/$fileName"; //die(); if (file_exists($Studentfile) == false) { die('It doesn\'t exist!'); } if (is_readable($Studentfile) == false) { die('It doesn\'t exist or we can\'t read it!'); } else { $upload = $db->sql_query("LOAD DATA LOCAL INFILE '".$Studentfile."' INTO TABLE ".$prefix."$table_name FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r'"); if (!$upload) {echo("<p>Error performing query: " . mysql_error() . "</p>");} } } I am getting Error performing query: The used command is not allowed with this MySQL version and I've also gotten "Can't get stat of 'Students.csv' (Errcode: 2)" I've used this with and without LOCAL. My website is on a different server than my MySQL database. The powers that be says it cannot be moved onto the same server. Why can't I load this file into MySQL? If this wont work can somebody give me a jump start on a parse routine where I could do inserts one at a time on about 300 or 400 records? Link to comment https://forums.phpfreaks.com/topic/102374-unable-to-load-data-infile/ Share on other sites More sharing options...
Donovan Posted April 22, 2008 Author Share Posted April 22, 2008 I've also tried this but nothing happens. $handle = fopen ($Studentfile, 'r'); while (($data = fgetcsv($handle, 1000, ',', '"')) !== FALSE) { $sql = $db->sql_query("INSERT INTO atlas_tl_students_temp VALUES ('". implode("','", $data)."')"); } Nothing gets inserted. Link to comment https://forums.phpfreaks.com/topic/102374-unable-to-load-data-infile/#findComment-524195 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.