Insert text file in a text field
Insert text file in a text field
am 18.10.2007 18:36:59 von electric_r
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 ?
Thank you .
Fab
Re: Insert text file in a text field
am 18.10.2007 19:29:54 von luiheidsgoeroe
On Thu, 18 Oct 2007 18:36:59 +0200, 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/fil e'))."')");
--
Rik Wasmus
Re: Insert text file in a text field
am 18.10.2007 19:33:25 von luiheidsgoeroe
On Thu, 18 Oct 2007 19:29:54 +0200, Rik Wasmus
wrote:
> On Thu, 18 Oct 2007 18:36:59 +0200, 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/fil e'))."')");
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
Re: Insert text file in a text field
am 18.10.2007 20:36:31 von Michael
On Oct 18, 6:36 pm, electri...@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 ?
>
> Thank you .
>
> Fab
I wrote a tutorial on uploading files into a mysql database.
You can read it here :http://wiki.greenquery.com/doku.php?
id=understanding_php_classes#creating_uploadhandler
I hope it's for some help to you.
//Michael
Re: Insert text file in a text field
am 19.10.2007 11:09:25 von Captain Paralytic
On 18 Oct, 17:36, electri...@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 ?
>
> Thank you .
>
> Fab
Do not multi-post. Cross-post if you must but don't multi
post It wastes people's time. http://www.blakjak.demon.co.uk/mul_crss.htm.
You have had answers from people on 2 different groups. If you had
cross posted instead of multi-posting, everyone would have seen that
the question had been answered.
Re: Insert text file in a text field
am 19.10.2007 13:59:13 von electric_r
On 18 Ott, 19:33, "Rik Wasmus" wrote:
> On Thu, 18 Oct 2007 19:29:54 +0200, Rik Wasmus
>
>
>
> wrote:
> > On Thu, 18 Oct 2007 18:36:59 +0200, 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/fil e'))."')");
>
> 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
Thank you very much .
Another question:
after I put a text file in a text field,
then, how can I read this field content and put it into
a php variable ?
Many thanks .
Fabrizio
Re: Insert text file in a text field
am 19.10.2007 14:24:20 von Jerry Stuckle
electric_r@yahoo.it wrote:
> On 18 Ott, 19:33, "Rik Wasmus" wrote:
>> On Thu, 18 Oct 2007 19:29:54 +0200, Rik Wasmus
>>
>>
>>
>> wrote:
>>> On Thu, 18 Oct 2007 18:36:59 +0200, 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/fil e'))."')");
>> 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
>
>
> Thank you very much .
>
> Another question:
> after I put a text file in a text field,
> then, how can I read this field content and put it into
> a php variable ?
>
> Many thanks .
>
> Fabrizio
>
>
http://www.php.net/manual/en/ref.mysql.php
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: Insert text file in a text field
am 19.10.2007 14:30:23 von henri
On Thu, 18 Oct 2007 09:36:59 -0700, electric_r 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 ?
textarea value="" something like that
>
> 2) How can I insert a microsoft word file into a BLOB field of a table ?
wouldn't it be more practical to just store the file's path instead of the file itself?
>
> Please, could you help me with a simple example ?
>
> Thank you .
>
> Fab
Re: Insert text file in a text field
am 19.10.2007 14:53:38 von Jerry Stuckle
Henri wrote:
> On Thu, 18 Oct 2007 09:36:59 -0700, electric_r 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 ?
>
> textarea value="" something like that
>
He's talking about a table in a SQL database.
>> 2) How can I insert a microsoft word file into a BLOB field of a table ?
>
> wouldn't it be more practical to just store the file's path instead of the file itself?
Not necessarily. Often times I'll store files in a database. A lot of
good reasons to do so (which should be discussed in a SQL newsgroup).
>> Please, could you help me with a simple example ?
>>
>> Thank you .
>>
>> Fab
>
>
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: Insert text file in a text field
am 20.10.2007 00:26:07 von Courtney
Henri wrote:
> On Thu, 18 Oct 2007 09:36:59 -0700, electric_r 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 ?
>
> textarea value="" something like that
>
>> 2) How can I insert a microsoft word file into a BLOB field of a table ?
>
> wouldn't it be more practical to just store the file's path instead of the file itself?
Actually it isn't.I ended up with EVERYTHING - files and images - in the
database simply because backing up the database then backs up EVERYTHING.
But I wouldn't use a text area to input a file..use the FILE input command.
>> Please, could you help me with a simple example ?
>>
>> Thank you .
>>
>> Fab
>
Re: Insert text file in a text field
am 20.10.2007 17:05:12 von henri
On Fri, 19 Oct 2007 23:26:07 +0100, The Natural Philosopher wrote:
> Henri wrote:
>> On Thu, 18 Oct 2007 09:36:59 -0700, electric_r 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 ?
>>
>> textarea value="" something like that
>>
>>> 2) How can I insert a microsoft word file into a BLOB field of a table
>>> ?
>>
>> wouldn't it be more practical to just store the file's path instead of
>> the file itself?
>
> Actually it isn't.I ended up with EVERYTHING - files and images - in the
> database simply because backing up the database then backs up
> EVERYTHING.
>
ok, good point. I was just not thinking in terms of back ups.
> But I wouldn't use a text area to input a file..use the FILE input
> command.
that was my misanderstanding the first question.
>
>>> Please, could you help me with a simple example ?
>>>
>>> Thank you .
>>>
>>> Fab
>>