I am very new in php/mysql. After searching everywhere I am asking here: my client has provided me one txt file, now I need a script to run frequently so that txt new data file will run and also at the same time update a database.
One option I have read about is Cron, but my client denied that solution, so I can only go with a PHP (or, if possible, ajax or jquery) based solution.
My code so far:
<?php
$string = file_get_contents("mytest.php/test1.txt", "r");
$myFile = "E:/path/test.txt";
$fh = fopen($myFile, 'w') or die("could not open: .mysql_error());
fwrite($fh,$string);
fclose($fh);
// Here is the connection file
$sql=mysql_connect("localhost","root","");
if(!$sql) {
die("couldnotconnect:", . mysql_error());
}
mysql_select_db("timer"); // databse name
$result=mysql_query("LOADDATAINFILE'$myFile'" ."INTOTABLEchangedtFieldsTERMINATEDBY''");
if (!$result) {
die("couldnotload . " . mysql_error());
}
?>
But this code is not working properly. Basically just another text file through I just want to update my database like:
Database Field:
Name (varchar 250)
LastModification timestamp