You are here: Re: Insert text file in a text field « PHP Programming Language « IT news, forums, messages
Re: Insert text file in a text field

Posted by Rik Wasmus on 10/18/07 17:33

On Thu, 18 Oct 2007 19:29:54 +0200, Rik Wasmus
<luiheidsgoeroe@hotmail.com> wrote:

> On Thu, 18 Oct 2007 18:36:59 +0200, <electric_r@yahoo.it> wrote:
>
>> Hallo,
>>
>> I have 2 questions:
>>
>> with php and mysql :
>>
>> 1) How can I insert a text file into a TEXT field of a table ?
>>
>> 2) How can I insert a microsoft word file into a BLOB field of a
>> table ?
>>
>> Please, could you help me with a simple example ?
>
>
> mysql_query("INSERT INTO tablename (fieldname) VALUES
> ('".mysql_real_escape_string(file_get_contents('/path/to/file'))."')");

Hmmm,
or: mysql_query("INSERT INTO tablename (fieldname) VALUES
(LOAD_FILE('/path/to/file'))");

For this you'd have to make sure:
- the database is on the same host as the file
- you have the FILE privilege
- the file is readable
- the filesize is less than max_allowed_packet bytes

--
Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация