Re: [PHP-DB] MySQL Insert via SQL?

2004-01-07 Thread ma
hi!

thx for your feedback! just wondered about the sql-documentation saying that
the file must be readable t all users. (at least session-files are only
read/write-able to the php-user. so i was uncertain.. imho your solution is
much nicer for saving the file in the db (allthough it may be a bad idea).

you're right ;) sometimes arguing can get anoying (e.g. which distribution
of linux is best and so on...)

greets ma


# life would be easier if i knew the source code...

> Von: "John W. Holmes" <[EMAIL PROTECTED]>
> Antworten an: [EMAIL PROTECTED]
> Datum: Wed, 07 Jan 2004 21:52:23 -0500
> An: [EMAIL PROTECTED]
> Cc: PHP-DB <[EMAIL PROTECTED]>
> Betreff: Re: [PHP-DB] MySQL Insert via SQL?
> 
> ma wrote:
> 
>> just a question: don't know it exactly: isn't it possible that the sql-user
>> on the server may not have enough rights to read the file?
> 
> Yeah, could be. The uploaded file is already somewhere that PHP can
> write to, though, so it's more than likely available for reading by any
> other user.
> 
>> anyway, i would save the file elsewhere on the server, because there are
>> remarkable performance-issues with big data (tried it once with storing
>> images for a photo-gallery). it is much faster saving the file in some
>> directory and just save the path to the file in the db; which on the other
>> hand, can lead to synchronisation-problems. what do you think about this
>> topic?
> 
> I agree entirely. I wouldn't put the file in the database either. I gave
> up on arguing that though since people seem so determined to do it. :)
> 
> -- 
> ---John Holmes...
> 
> Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
> 
> php|architect: The Magazine for PHP Professionals ­ www.phparch.com
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] MySQL Insert via SQL?

2004-01-07 Thread John W. Holmes
ma wrote:

just a question: don't know it exactly: isn't it possible that the sql-user
on the server may not have enough rights to read the file?
Yeah, could be. The uploaded file is already somewhere that PHP can 
write to, though, so it's more than likely available for reading by any 
other user.

anyway, i would save the file elsewhere on the server, because there are
remarkable performance-issues with big data (tried it once with storing
images for a photo-gallery). it is much faster saving the file in some
directory and just save the path to the file in the db; which on the other
hand, can lead to synchronisation-problems. what do you think about this
topic?
I agree entirely. I wouldn't put the file in the database either. I gave 
up on arguing that though since people seem so determined to do it. :)

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] MySQL Insert via SQL?

2004-01-07 Thread ma
hi!

just a question: don't know it exactly: isn't it possible that the sql-user
on the server may not have enough rights to read the file?

anyway, i would save the file elsewhere on the server, because there are
remarkable performance-issues with big data (tried it once with storing
images for a photo-gallery). it is much faster saving the file in some
directory and just save the path to the file in the db; which on the other
hand, can lead to synchronisation-problems. what do you think about this
topic?

thx -ma

# life would be easier if i knew the source code...

> Von: "John W. Holmes" <[EMAIL PROTECTED]>
> Antworten an: [EMAIL PROTECTED]
> Datum: Wed, 07 Jan 2004 21:29:20 -0500
> An: Will W <[EMAIL PROTECTED]>
> Cc: PHP DB <[EMAIL PROTECTED]>
> Betreff: Re: [PHP-DB] MySQL Insert
> 
> Will W wrote:
> 
>> Can anyone tell me how to insert a file,
>> say a .doc, .txt or a .rtf file into a table from an upload form??
> 
> How about just this:
> 
> $query = "INSERT INTO Table (orig_name, size, mime_type, data) VALUES
> ('{$_FILES['userfile']['name']}', '{$_FILES['userfile']['size']}',
> '{$_FILES['userfile']['type']}',LOAD_FILE('{$_FILES['userfile']['tmp_name']}')
> )";
> 
> Adapt to your needs. No need for PHP to read the file when you can just
> let MySQL do it. :)
> 
> -- 
> ---John Holmes...
> 
> Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
> 
> php|architect: The Magazine for PHP Professionals ­ www.phparch.com
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] MySQL Insert

2004-01-07 Thread John W. Holmes
Will W wrote:

Can anyone tell me how to insert a file, 
say a .doc, .txt or a .rtf file into a table from an upload form??
How about just this:

$query = "INSERT INTO Table (orig_name, size, mime_type, data) VALUES 
('{$_FILES['userfile']['name']}', '{$_FILES['userfile']['size']}', 
'{$_FILES['userfile']['type']}',LOAD_FILE('{$_FILES['userfile']['tmp_name']}'))";

Adapt to your needs. No need for PHP to read the file when you can just 
let MySQL do it. :)

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] MySQL Insert

2004-01-07 Thread ma
hi!

no problem... people should help each other ;)

so: no there is no difference. if you want people to have the possibility to
download the file there are certain things to remember of. just a short
example:



greets -ma

# life would be easier if i knew the source code...

> Von: "Will W" <[EMAIL PROTECTED]>
> Antworten an: [EMAIL PROTECTED]
> Datum: Wed, 7 Jan 2004 21:03:40 -0500
> An: <[EMAIL PROTECTED]>
> Betreff: Re: [PHP-DB] MySQL Insert
> 
> Thanks!!! :)
> 
> For getting the info from the database is it like all the rest or is there a
> certain way to get those types of files from the database?
> 
> Thanks,
> ~~Will~~
> 
> - Original Message -
> From: "ma" <[EMAIL PROTECTED]>
> To: "PHP-DB" <[EMAIL PROTECTED]>
> Sent: Wednesday, January 07, 2004 8:42 PM
> Subject: Re2: [PHP-DB] MySQL Insert
> 
> 
>> hi!
>> 
>> just to add:
>> 
>> use file() only if you run php 4.3.0 or higher.
>> 
>> if this is not the case use this syntax (its binary safe):
>> 
>> $fp = fopen($_FILES['myFile']['tmp_name'], 'r'); # on windows use 'rb'
>> instead of 'r'
>> $data = fread($fp, file_size($_FILES['myFile']['tmp_name']));
>> fclose($fp);
>> 
>> instead of $data = join(etc);
>> 
>> greets - ma
>> 
>> # life would be easier if i knew the source code...
>> 
>> --
>> PHP Database Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>> 
>> 
>> 
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re2: [PHP-DB] MySQL Insert

2004-01-07 Thread ma
hi!

just to add:

use file() only if you run php 4.3.0 or higher.

if this is not the case use this syntax (its binary safe):

$fp = fopen($_FILES['myFile']['tmp_name'], 'r'); # on windows use 'rb'
instead of 'r'
$data = fread($fp, file_size($_FILES['myFile']['tmp_name']));
fclose($fp);

instead of $data = join(etc);

greets - ma

# life would be easier if i knew the source code...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] MySQL Insert

2004-01-07 Thread ma
hi

there are several ways of saving the data within a file.
you can save it plain or binary. if you want to save a file in the db i
suggest using the field-type BLOB

short example:

to create the table:

CREATE TABLE `files` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`fileName` VARCHAR(255) NOT NULL,
`data` BLOB,
PRIMARY KEY (`id`)
) TYPE=MyISAM

the html-form:


File: 



the php-script:



for further info go&see:
http://www.php.net/manual/en/features.file-upload.php


hth?

greetings -ma

# life would be easier, if i knew the source code...

> Von: "Will W" <[EMAIL PROTECTED]>
> Antworten an: [EMAIL PROTECTED]
> Datum: Wed, 7 Jan 2004 20:21:15 -0500
> An: "PHP DB" <[EMAIL PROTECTED]>
> Betreff: [PHP-DB] MySQL Insert
> 
> Hello Everyone,
> Can anyone tell me how to insert a file, say a .doc, .txt or a .rtf file into
> a table from an upload form??
> 
> Thanks in advance,
> ~~Will~~
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] MySQL Insert

2004-01-07 Thread Will W
Hello Everyone,
Can anyone tell me how to insert a file, say a .doc, .txt or a .rtf file into a table 
from an upload form??

Thanks in advance,
~~Will~~


Re: [PHP-DB] MySQL Insert Select statement

2002-10-19 Thread Jeffrey_N_Dyke

what was the error?



   
  
"dwalker"  
  
, 
"'professional php'"   
splus.com> <[EMAIL PROTECTED]>, 
<[EMAIL PROTECTED]>,   
   <[EMAIL PROTECTED]> 
  
10/19/2002 08:32 PM   cc:  
  
    Please respond to Subject: Re: [PHP-DB] MySQL 
Insert Select statement
"dwalker"  
  
   
  
   
  




For some reason the Insert Select statement returned an ERROR and I had to
resort to

INSERT INTO Products
(ProductName,Size,SuggestedRetailPrice,ProductCategory,ManufacturerName)

SELECT *

FROM kalproduct ;

Is there a noticeable reason why:

INSERT INTO Products
(ProductName,Size,SuggestedRetailPrice,ProductCategory,ManufacturerName)

SELECT(kalproduct.Product, kalproduct.size, kalproduct.SRP,
kalproduct.Cat, kalproduct.manname)

FROM kalproduct ;

would have returned an error message??  I don't want to have to create
multiple tables for the purpose of inserting into others.

-Original Message-
From: John W. Holmes <[EMAIL PROTECTED]>
To: 'dwalker' <[EMAIL PROTECTED]>; 'professional php'
<[EMAIL PROTECTED]>; [EMAIL PROTECTED] <[EMAIL PROTECTED]>;
[EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Saturday, October 19, 2002 7:24 PM
Subject: RE: [PHP-DB] MySQL Insert Select statement


>That's how you do it. Hopefully you've figured it out already.
>
>
>
>---John Holmes.
>
>
>
>-Original Message-
>From: dwalker [mailto:dwalker@;healthyproductsplus.com]
>Sent: Saturday, October 19, 2002 7:51 PM
>To: professional php; [EMAIL PROTECTED]; [EMAIL PROTECTED]
>Subject: [PHP-DB] MySQL Insert Select statement
>
>
>
>While reading the MySQL manual for INSERT SELECT, I was not able to
>determine how to include all 5 fields of one table into another table
>(containing 100 fields) into SPECIFIC data fields.  Do I need to
>explicitly list all the fields within the table of 5 fields?  If so,
>would the statement be:
>
>
>
>INSERT INTO Products
>(ProductName,Size,SuggestedRetailPrice,ProductCategory,ManufacturerName)
>
>SELECT(kalproduct.Product, kalproduct.size, kalproduct.SRP,
>kalproduct.Cat, kalproduct.manname)
>
>FROM kalproduct
>
>;
>
>
>
>
>
>
>
>Thanking you in advance.
>
>
>
>P.S.  I'd give it a try, but I'm trying to move 500 partial records into
>a table containing at least 2000 records -- didn't want to start from
>scratch.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>This email message and all attachments transmitted herewith are trade
>secret and/or confidential information intended only for the
> viewing and use of addressee.  If the reader of this message
> is not the intended recipient, you are hereby notified that
>any review, use, communication, dissemination, distribution
>or copying of this communication is prohibited.  If you have
>received this communication is error, please notify the sender
>immediately by telephone or electronic mail, and delete this
>message and all copies and backups thereof.
>
>
>
>Thank you for your cooperation.
>
>


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] MySQL Insert Select statement

2002-10-19 Thread dwalker
For some reason the Insert Select statement returned an ERROR and I had to
resort to

INSERT INTO Products
(ProductName,Size,SuggestedRetailPrice,ProductCategory,ManufacturerName)

SELECT *

FROM kalproduct ;

Is there a noticeable reason why:

INSERT INTO Products
(ProductName,Size,SuggestedRetailPrice,ProductCategory,ManufacturerName)

SELECT(kalproduct.Product, kalproduct.size, kalproduct.SRP,
kalproduct.Cat, kalproduct.manname)

FROM kalproduct ;

would have returned an error message??  I don't want to have to create
multiple tables for the purpose of inserting into others.

-Original Message-
From: John W. Holmes <[EMAIL PROTECTED]>
To: 'dwalker' <[EMAIL PROTECTED]>; 'professional php'
<[EMAIL PROTECTED]>; [EMAIL PROTECTED] <[EMAIL PROTECTED]>;
[EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Saturday, October 19, 2002 7:24 PM
Subject: RE: [PHP-DB] MySQL Insert Select statement


>That's how you do it. Hopefully you've figured it out already.
>
>
>
>---John Holmes.
>
>
>
>-Original Message-
>From: dwalker [mailto:dwalker@;healthyproductsplus.com]
>Sent: Saturday, October 19, 2002 7:51 PM
>To: professional php; [EMAIL PROTECTED]; [EMAIL PROTECTED]
>Subject: [PHP-DB] MySQL Insert Select statement
>
>
>
>While reading the MySQL manual for INSERT SELECT, I was not able to
>determine how to include all 5 fields of one table into another table
>(containing 100 fields) into SPECIFIC data fields.  Do I need to
>explicitly list all the fields within the table of 5 fields?  If so,
>would the statement be:
>
>
>
>INSERT INTO Products
>(ProductName,Size,SuggestedRetailPrice,ProductCategory,ManufacturerName)
>
>SELECT(kalproduct.Product, kalproduct.size, kalproduct.SRP,
>kalproduct.Cat, kalproduct.manname)
>
>FROM kalproduct
>
>;
>
>
>
>
>
>
>
>Thanking you in advance.
>
>
>
>P.S.  I'd give it a try, but I'm trying to move 500 partial records into
>a table containing at least 2000 records -- didn't want to start from
>scratch.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>This email message and all attachments transmitted herewith are trade
>secret and/or confidential information intended only for the
> viewing and use of addressee.  If the reader of this message
> is not the intended recipient, you are hereby notified that
>any review, use, communication, dissemination, distribution
>or copying of this communication is prohibited.  If you have
>received this communication is error, please notify the sender
>immediately by telephone or electronic mail, and delete this
>message and all copies and backups thereof.
>
>
>
>Thank you for your cooperation.
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] MySQL Insert Select statement

2002-10-19 Thread John W. Holmes
That's how you do it. Hopefully you've figured it out already. 

 

---John Holmes.

 

-Original Message-
From: dwalker [mailto:dwalker@;healthyproductsplus.com] 
Sent: Saturday, October 19, 2002 7:51 PM
To: professional php; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: [PHP-DB] MySQL Insert Select statement

 

While reading the MySQL manual for INSERT SELECT, I was not able to
determine how to include all 5 fields of one table into another table
(containing 100 fields) into SPECIFIC data fields.  Do I need to
explicitly list all the fields within the table of 5 fields?  If so,
would the statement be:

 

INSERT INTO Products
(ProductName,Size,SuggestedRetailPrice,ProductCategory,ManufacturerName)

SELECT(kalproduct.Product, kalproduct.size, kalproduct.SRP,
kalproduct.Cat, kalproduct.manname)

FROM kalproduct 

;

 

 

 

Thanking you in advance.

 

P.S.  I'd give it a try, but I'm trying to move 500 partial records into
a table containing at least 2000 records -- didn't want to start from
scratch.

 

 

 

 

 

 

 

 

 

 

This email message and all attachments transmitted herewith are trade
secret and/or confidential information intended only for the
 viewing and use of addressee.  If the reader of this message
 is not the intended recipient, you are hereby notified that 
any review, use, communication, dissemination, distribution 
or copying of this communication is prohibited.  If you have 
received this communication is error, please notify the sender 
immediately by telephone or electronic mail, and delete this 
message and all copies and backups thereof.  

 

Thank you for your cooperation.




[PHP-DB] MySQL Insert Select statement

2002-10-19 Thread dwalker



While reading the MySQL manual for INSERT SELECT, I was 
not able to determine how to include all 5 fields of one table into another 
table (containing 100 fields) into SPECIFIC data fields.  Do I need to 
explicitly list all the fields within the table of 5 fields?  If so, would 
the statement be:
 
INSERT INTO Products 
(ProductName,Size,SuggestedRetailPrice,ProductCategory,ManufacturerName)
SELECT(kalproduct.Product, kalproduct.size, 
kalproduct.SRP, kalproduct.Cat, kalproduct.manname)
FROM kalproduct 
;
 
 
 
Thanking you in advance.
 
P.S.  I'd give it a try, but I'm trying to move 500 
partial records into a table containing at least 2000 records -- didn't want to 
start from scratch.
 
 
 
 
 
 
 
 
 
 
This email message and all attachments transmitted herewith 
are tradesecret and/or confidential information intended only for 
the viewing and use of addressee.  If the reader of this 
message is not the intended recipient, you are hereby notified that 
any review, use, communication, dissemination, distribution or copying 
of this communication is prohibited.  If you have received this 
communication is error, please notify the sender immediately by telephone or 
electronic mail, and delete this message and all copies and backups 
thereof.  
 
Thank you for your cooperation.
-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] MYSQL: INsert html form data;

2002-05-01 Thread [EMAIL PROTECTED]

I'm not sure what you're asking but the fields are set to varchar(40) which
will accommodate the information I have been insertinging...

/T


on 4/30/02 9:00 PM, Neil at [EMAIL PROTECTED] wrote:

> Have you checked to see that id tidying is set to the amount equal to the
> fields in your form.
> - Original Message -
> From: "Info_Best-IT" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, April 30, 2002 4:56 PM
> Subject: [PHP-DB] MYSQL: INsert html form data;
> 
> 
>> I have a problem writing form data to a table in MySQL.  I have an
> action.php file
>> that it called when the information is submitted and it looks something
> like this:
>> 
>> > 
>>   $connection = mysql_connect("@localhost","root", "password")
>> or die ("The DataBase is Down!");
>> 
>>mysql_select_db("web_feedback", $connection)
>> or die ("I Can't connect at database!");
>> 
>>$query_st_name = mysql_query("INSERT into name_email (col1)
> values($name)");
>>$query_st_email = mysql_query("INSERT into name_email (col2)
> values($email)");
>> mysql_close($connection); // Close this connection
>> ?>
>> 
>> Thanks for submitting your name and e-mail, I will contact you soon to
> discuss your
>> interest in more detail.
>> 
>> I can tell the file is being called since the previous message appears in
> the window.
>> But when I go to check out my table there are no records.  Anyone see
> where this may
>> be going wrong?  I also set a php_error log path in the PHP.ini and I do
> not get any
>> errors written there.  I think it may be something else but not sure
> what...
>> 
>> the site: www.best-it.biz
>> the link: services
>> thanks in advance!
>> /Tim
>> 
>> 
>> --
>> PHP Database Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>> 
>> 
> 
> 
> 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] MYSQL: INsert html form data;

2002-04-30 Thread Info_Best-IT

I have a problem writing form data to a table in MySQL.  I have an action.php file 
that it called when the information is submitted and it looks something like this:



Thanks for submitting your name and e-mail, I will contact you soon to discuss your
interest in more detail.

I can tell the file is being called since the previous message appears in the window.  
 
But when I go to check out my table there are no records.  Anyone see where this may 
be going wrong?  I also set a php_error log path in the PHP.ini and I do not get any 
errors written there.  I think it may be something else but not sure what...

the site: www.best-it.biz
the link: services
thanks in advance!
/Tim


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php