Advanced Search

Results 1 to 2 of 2

Thread: updating database using cron

  1. #1
    Join Date
    Aug 2005
    Posts
    174
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default updating database using cron

    Hey,

    I'm using the script below to update my database from a file, but (since changing hosts) i get an error when the script is being called from a cron job - yet it works calling the script from a browser?!

    Code:
    Error loading data file.<br>File 'xxxx.csv' not found (Errcode: 2)
    PHP Code:

    <?php
    ## Connect to a local database server (or die) ##
    $dbH mysql_connect('localhost''username''password') or die('Could not connect to MySQL server.<br>' mysql_error());

    ## Select the database to insert to ##
    mysql_select_db('database') or die('Could not select database.<br>') . mysql_error();

    ## CSV file to read in ##

    mysql_query('DELETE FROM Offers');
    mysql_query('LOAD DATA LOCAL INFILE "xxxx.csv" INTO TABLE Offers FIELDS TERMINATED BY "," ENCLOSED BY """" LINES TERMINATED BY "\n" ignore 0 lines;') or die('Error loading data file.<br>' mysql_error());


    ## Close database connection when finished ##
    mysql_close($dbH);
    ?>

  2. #2
    Join Date
    Aug 2005
    Posts
    174
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    managed to sort this out.. used the complete path
    HTML Code:
    /home/username/public_html

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •