Link to home
Start Free TrialLog in
Avatar of Zado
ZadoFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Read txt file with php and save it to mysql database

Hi,


I have a file on ftp: file.txt
I need a script to read it and save each line to different mysql cell, but same row.
Example:

FILE:
Sam
Pass
Other content
here

DATABASE:
id
name
password
comments

What I want here is: open the file, read it line by line and save it like so:
first line (Sam) to 'name' column
second line (Pass) to 'password' column
other lines (Other content here) to 'comments' column

I know I need to use fopen, fclose etc. but I need full script.


Thanks for any help.
SOLUTION
Avatar of _-MYFOX-_
_-MYFOX-_
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Zado

ASKER

Thanks for your help