Jump to content

Recommended Posts

The file I wish to run resides on the server xxx.com/test.cvs

 

I want to set a cron job to run the script below every day.

 

<?php

 

 

 

 

include "connect.php";

if(isset($_POST['submit']))

  {

    $filename=$_POST['filename'];

    $handle = fopen("$filename", "r");

    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)

    {

   

      $import="INSERT into prices values('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]','$data[7]','$data[8]','$data[9]','$data[10]')";

      mysql_query($import) or die(mysql_error());

    }

    fclose($handle);

    print "Import done";

 

  }

  else

  {

 

      print "<form action='csv.php' method='post'>";

      print "Type file name to import:<br>";

      print "<input type='text' name='filename' size='20'><br>";

      print "<input type='submit' name='submit' value='submit'></form>";

  }

 

?>

 

 

Please someone help me restructure it cos cron job can not press the submit button.

 

Thx all

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.