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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fopen/fwrite and/or FTP

Status
Not open for further replies.

daybase

Technical User
Dec 13, 2002
115
GB
Stupid question time - is it possible to write to a file from a server to a local PC or write to a file on the server then download to the local PC using FTP functions.

What I am looking to do is compare data held in an SQL database online with an Access equivalent on my laptop. The current solution is to use PHP to output a page as comma delimited format on screen then manually save to c:\mydownloads\compare.txt. Access then reads the text file and compares data. I am looking to simplify and automate the process but as I am pretty new to PHP I am unsure whether it is possible. Any advice gratefully received.
 
answer to all of the above is yes. in most cases you will need network access to the local pc from the remote server.

but ... would it not be easier to set up a remote odbc connection from your server to your pc and then query the access database through odbc and do your comparison through that mechanism?

better still, get rid of access altogether and use a local mysql implementation. you can use mysql as the back end to an access application.

then set up a server replication function between the two instances.
 
Bit beyond my capabilities I am afraid. Teaching myself as I go and working from examples in manuals. PHP current project so I will have to leave the ODBC etc for later. The server is not networked - it is a managed server via ISP so all scripts rum over internet.
 
then it is networked. it does not need to be on the same subnet as you to be able to communicate with you!

if you are using windows, just go to the control panel and look for odbc and follow the prompts. make sure that your computer is exposed to the internet on the odbc port (tcp 7210). obviously close it off as soon as you are finished.

using odbc is (pretty much) as simple as mysql. but you use odbc_* functions in php rather than mysql_*. there's plenty of good stuff in the php manual.
 
Thanks for the advice but I have not mastered sql yet so will persevere with the PHP option for now. Could you give me some pointers to using fwrite - in particular how to write the file from the server to local directory c:\mydownloads
 
you cant do that unless you have access from the server to the local computer.
just output the csv to the screen and cut and paste. or set some headers and send it as a file to the browse (see the header() function in the manual).

odbc will be your easiest solution. it is not a function of mastering anything - it is very straightforward.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top