View Full Version : Save Documents on MYSQL DB using PHP script

03-09-2008, 01:58 PM

Please I need help. I need to download URL and save the content into MYSQL database as word documents. I used to save the URL only because I didn't needed the content of the URL but now I reach a stage where I'll need to save the content of these URL in database and browse them one by one and analyse them this why i need to know how I can save them into 1 table with the URL as well.!! I have MYSQL background but I know how to save fields with limited length . how can I save files instead of limited length content????

Hope I'll get answer as soon as possible


03-09-2008, 07:05 PM
Use a TEXT/MEDIUMTEXT/LONGTEXT field. (manual (http://dev.mysql.com/doc/refman/5.0/en/string-type-overview.html))

03-09-2008, 11:13 PM
Thanks for your reply.
this will take huge amount of memory to save around 1000 URL content right!! is this the only way or will there be any alternative to save the content as Separate files and link them to the DB field?

And could any one tell me the best way to get the content of the URL page to save them in the DB? I need the content as plain text, is there any function in PHP allow me to do that!!

many thanks in advance

03-09-2008, 11:31 PM
It won't take up large amounts of memory unless you're trying to retrieve several large ones at a time. But, you could store them in files, and reference the files in the database if you wanted to.
file_put_contents() (http://php.net/file_put_contents) is the easiest way to save a file.

03-09-2008, 11:53 PM
Thank you very much for your helpful replies Inigoesdr,

I still need to know now how can I extract the content of the web pages as lain text and save them in the table.

Many thanks

03-10-2008, 12:10 AM
You can use file_get_contents() (http://php.net/file_get_contents) to get a webpage as long as your host supports url fopen wrappers(check your phpinfo).