Advertisement
Guest User

Untitled

a guest
Sep 19th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <title>HTML Tutorial</title>
  4.  
  5. <body>
  6.  
  7. <?php
  8.  
  9. $servername = "localhost";
  10. $username = "root";
  11. $password = "";
  12.  
  13. // Create connection
  14. $conn = mysqli_connect($servername, $username,$password,"movieclub");
  15.  
  16. // Check connection
  17. if (!$conn) {
  18. die("Connection failed: " . mysqli_connect_error());
  19. }
  20. //successful connection,
  21.  
  22.  
  23. //Opens and imports movieclub.csv file
  24. $file = fopen("TRY.csv",'r');
  25.  
  26. while(! feof($file))
  27. {
  28. $CurrentLine = (fgetcsv($file));
  29. if ($CurrentLine != "")
  30. {
  31. $result = mysqli_query($conn, "SELECT Title FROM movie WHERE Title='".$CurrentLine[0]."'");
  32.  
  33. $movieQuery = mysqli_query($conn,"INSERT INTO movie(Title, Director, Producer, Release_Date, Running Time (Mins), Genre, Starring, Distributor) VALUES ('".$CurrentLine[0]."', '".$CurrentLine[1]."', '".$CurrentLine[2]."', '".$CurrentLine[3]."', '".$CurrentLine[4]."', '".$CurrentLine[5]."', '".$CurrentLine[6]."','".$CurrentLine[7]."','".$CurrentLine[8]."' )");
  34.  
  35. print_r(mysqli_error($conn));
  36. mysqli_close($conn);
  37. ?>
  38.  
  39. </body>
  40. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement