Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto update MySQLdb

Status
Not open for further replies.

pookie62

Technical User
Oct 22, 2004
139
GB
Hi all,
Does anyone have a working phpscript (and the will to share ;-)) that can read and update a MySQL db (hosted) with an uploaded text file ? (By itself..)
See my little project partly here:
I have no clue on where to start, would appreciate very much !!

cheers
Hans
 
Use task scheduler or cron to automate the process...write your script as you normally would, checking for the existance of the file, and then running the update (don't output any data to the browser, so no print/echo commands) when you script works the way it should, use task scheduler on windows or cron on *nix systems to run the script at predetermined times (intervals)

Bastien

I wish my computer would do what I want it to do,
instead of what I tell it to do...
 
Hi Bastien,
I don't think this can be done on a ISP hosted website ??
DO have a sample update script ?
Thanks
Hans
 
Many site offer cron. Its a part of the cpanel install I have on my site

The update would just be the script needed to open the file, read the contents, and loop thru that array to load the file into the db table


Bastien

I wish my computer would do what I want it to do,
instead of what I tell it to do...
 
Hi Bastien,
I'll check if cron is available..
Concerning the script: You hit the nail on the head..
Unfortunately I don't have the knowledge to create scripts from scratch.. that's why I keep asking for an example..
Sorry for being not that experienced..
 
Did you consider trying the manual
Code:
<?php
$row = 1;
$handle = fopen("test.csv", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
   $num = count($data);
   echo "<p> $num fields in line $row: <br /></p>\n";
   $row++;
   for ($c=0; $c < $num; $c++) {
       //the sql call to insert the data goes here
       echo $data[$c] . "<br />\n";
   }
}
fclose($handle);
?>

Bastien

I wish my computer would do what I want it to do,
instead of what I tell it to do...
 
Thanks Bastien,
I'll start working with this..
You'll probably see me back ;-)
Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top