Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm doing a movie database project to learn MySQL and also PHP. So far, I've Python to search a folder and see if a file was added or removed. If it has detected that a file was added or removed, it will run another Python script that gets the name of the movie file and then searches OMDb and returns certain values (like title, year, plot, rating, etc). This information is then stored into a file for MySQL to use.

The file is formatted like

"\N      Title      Year      Plot      Rating"

In my PHP file I have this code:

PHP
if (!mysqli_query($con, "LOAD DATA LOCAL INFILE '/home/user/movies.txt' INTO TABLE films")) {
    printf("Errormessage: %s\n", mysqli_error($con));
}

$result = mysqli_query($con, "SELECT title, yr, genre, plot, rating FROM films") or die("Unable to query.");


And then after that I have a loop which echoes some HTML to produce a table.

This all works fine. When I add a file, Python detects it, gets the movie info from the internet and adds the info to a file, and then PHP loads that information to a MySQL database and then displays it.

However, when I remove a file from the directory that Python looks in, the file for the MySQL db is updated, but MySQL still has the removed movie/file in the database.

How could I get MySQL (through PHP) to load the data from the file, but replacing it instead of appending it?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900