Advertisement
Guest User

Untitled

a guest
Feb 19th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. <?php
  2.  
  3. $host = 'localhost';
  4. $user = 'fulltime_admin';
  5. $pass = 'jordan23';
  6. $database = 'fulltime_db';
  7.  
  8. $db = mysql_connect($host, $user, $pass);
  9. mysql_query($database, $db);
  10.  
  11.  
  12. //////////////////////////////// EDIT ////////////////////////////////////
  13.  
  14. $redirect_num = 500; // Select how many rows to insert each time before refresh.
  15. // More rows = faster insertion. However cannot be too high otherwise it will timeout.
  16.  
  17. $filename = "ps4_emails.csv"; // The file we are going to get the data from...
  18.  
  19. $table = "`ps4_emails`";
  20.  
  21.  
  22. ////////////////////////////// END EDIT //////////////////////////////////
  23.  
  24. $file = file($filename);
  25. $lines = count($file);
  26.  
  27. // Have we just redirected?
  28. $nextline = $_GET['nextline'];
  29. if (!isset($nextline)){
  30. $nextline = 0;
  31. }
  32.  
  33. $query = "INSERT INTO ".$table." (email) VALUES ('".$final_line[0]."')";
  34.  
  35. for ($line=$nextline; $line<=$lines; $line++){
  36.  
  37. $final_line = explode(",", $file[$line]);
  38.  
  39. if ($line!=$lines){
  40. mysql_query($query,$db);
  41.  
  42. }
  43.  
  44. if ($line % $redirect_num){
  45.  
  46. // something needs to go here
  47. }
  48. else {
  49. $nextline = $line+1;
  50. exit ('<meta http-equiv="refresh" content="0;url=texttomysqlemails.php?nextline='.$nextline.'" />');
  51. }
  52.  
  53. echo ( $line==$lines ) ? "Done" : "";
  54.  
  55. }
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement