PHP/SQL stats tracking?

Soldato
Joined
20 Aug 2003
Posts
6,703
Location
Pembrokeshire
Evening
Basically I need to transfer, by FTP, the contents of a text file to a MySQL table so that I can call the table(s) in php and output the results to a web page. I think that I have the second part of this but have no idea about getting the data from one server to MySQL and into tables so that I can call it.
I seem to recall some of you doing this for stats tracking previously, any help appreciated. :)
 
You'll need to give a bit more info than that - what format is the data in your text file? Delimited fields, fixed width, database dump?

If you are trying to take the data from an existing MySQL database then you can use mysqldump {params} > dump.sql to extract the desired data and then mysql {params} < dump.sql to import it on the receiving end.
 
Time stamped, delimited (semi colon). It is a text file, generated by an application in real time, no database. I need FTP the contents to another server where it can be put into a MySQL db so that I can then extract the desired data so that I can use PHP (or similar/better) to process the data into a format that can be output for inclusion on a webpage. It will also be a requirement that after the initial dump the database is appended at a given interval, not a complete dump everytime.

Anyway, the thing that is killing me (at the moment, there will likely be other problems) is obtaining the data from the remote server for processing.
 
thread revival time. Been busy with other things :(

for clarity, I need to access a flat file via ftp (preferably at a given time) is this even possible with php?
I can handle the data once I get it, I just dont know how to get it :(
Ahh ok, it is possible to download the file from FTP file 'a' to open local file 'b', the problem is that the file will get progressively larger (currently a hair over 1gb) so I dont want to have to transfer the entire file every time....any ideas?
 
Last edited:
do you have a database management system like phpMyAdmin available? IIRC you can import various types of data format into that and then access it as a normal MySQL table/db.

Alternatively, php supports the same fopen/read/write functions that C does, so you could load up the file in a php page, parse the data and insert it into the table.

eg
Code:
<?php
// get contents of a file into a string
$filename = "/usr/local/something.txt";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
?>

From: http://uk3.php.net/fread
 
Yeah the plan is to use the data to update some mySQL tables. What I need to do is just access the most recent data from the original text file instead of all of it (1gb and progressively larger file gets and insertions on a daily basis would probably get my hosting accounts dropped)
 
Back
Top Bottom