Guest User

Untitled

a guest
Jun 15th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. mysql_connect("localhost","postfix","postfix");
  2. mysql_select_db("postfix");
  3.  
  4. $databasehost = "localhost";
  5. $databasename = "test";
  6. $databasetable = "sample";
  7. $databaseusername ="test";
  8. $databasepassword = "";
  9. $fieldseparator = ",";
  10. $lineseparator = "\n";
  11. $csvfile = "Memberships.csv2";
  12.  
  13. $addauto = 0;
  14.  
  15. $save = 1;
  16. $outputfile = "output.sql";
  17.  
  18.  
  19.  
  20. $file = fopen($csvfile,"r");
  21. $size = filesize($csvfile);
  22.  
  23.  
  24. $csvcontent = fread($file,$size);
  25.  
  26. fclose($file);
  27.  
  28. $lines = 0;
  29. $queries = "";
  30.  
  31.  
  32. $linearray = array();
  33.  
  34. foreach(split($lineseparator,$csvcontent) as $line) {
  35.  
  36. $lines++;
  37.  
  38. $line = trim($line," \t");
  39.  
  40.  
  41. $line = str_replace("\r","",$line);
  42. $line = str_replace('"', "", $line);
  43. $linearray = explode($fieldseparator,$line);
  44.  
  45. $linemysql = implode("','",$linearray);
  46.  
  47.  
  48.  
  49. $linearray = array_map('mysql_real_escape_string', $linearray);
Add Comment
Please, Sign In to add comment