Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Updating a file

Options
  • 29-04-2010 9:04pm
    #1
    Registered Users Posts: 7


    Hi there, i'm presently doing a project which requires a file to be updated by another file of same format.

    The operating system I'm using is windows and the project is a php based webpage. I need to update a file every xx mins and store it in my database.

    I'm not sure how to approach this, anybody have any suggestions??

    Thanks


Comments

  • Registered Users Posts: 647 ✭✭✭Freddio


    the following code will overwrite

    $myFile = "testFile.txt";
    $fh = fopen($myFile, 'w') or die("can't open file");
    $stringData = "Floppy Jalopy\n";
    fwrite($fh, $stringData);
    fclose($fh);


    the following code will continue adding everytime its run

    $myFile = "testFile.txt";
    $fh = fopen($myFile, 'a') or die("can't open file");
    $stringData = "Floppy Jalopy\n";
    fwrite($fh, $stringData);
    fclose($fh);

    updating the database would depend on your schema (structure) but once you have established the connection to the database on the web page you can then send update statements using mysql_query()

    php.net is the bible for this stuff

    because your using a windows machine you will have to call the php script on a scheduler but if the script is available on the net you could call it up periodically from any other machine that's permanently on if you have limited web hosting


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    I guess this file is been updated by some other application.

    You could schedule a script to execute every xx minutes, that takes in the file to read and then updates the database based on the contents. In Linux, you could use cron but on windows you could use scheduled tasks to run php.exe to execute a script periodically.


Advertisement