Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <title>HTML Tutorial</title>
- <body>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- // Create connection
- $conn = mysqli_connect($servername, $username,$password,"movieclub");
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- //successful connection,
- //Opens and imports movieclub.csv file
- $file = fopen("TRY.csv",'r');
- while(! feof($file))
- {
- $CurrentLine = (fgetcsv($file));
- if ($CurrentLine != "")
- {
- $result = mysqli_query($conn, "SELECT Title FROM movie WHERE Title='".$CurrentLine[0]."'");
- $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]."' )");
- print_r(mysqli_error($conn));
- mysqli_close($conn);
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement