Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mysql_connect("localhost","postfix","postfix");
- mysql_select_db("postfix");
- $databasehost = "localhost";
- $databasename = "test";
- $databasetable = "sample";
- $databaseusername ="test";
- $databasepassword = "";
- $fieldseparator = ",";
- $lineseparator = "\n";
- $csvfile = "Memberships.csv2";
- $addauto = 0;
- $save = 1;
- $outputfile = "output.sql";
- $file = fopen($csvfile,"r");
- $size = filesize($csvfile);
- $csvcontent = fread($file,$size);
- fclose($file);
- $lines = 0;
- $queries = "";
- $linearray = array();
- foreach(split($lineseparator,$csvcontent) as $line) {
- $lines++;
- $line = trim($line," \t");
- $line = str_replace("\r","",$line);
- $line = str_replace('"', "", $line);
- $linearray = explode($fieldseparator,$line);
- $linemysql = implode("','",$linearray);
- $linearray = array_map('mysql_real_escape_string', $linearray);
Add Comment
Please, Sign In to add comment