Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
-
nirma78
- Forum Commoner
- Posts: 42
- Joined: Wed Sep 17, 2003 2:02 pm
Post
by nirma78 »
Hi
I am trying to insert an uploaded file into the database.
I found that it can be done with a query as below :
insert into tablename(blobfield) values(load_file('/path/to/file.txt'))
I am running the code from windows machine which uses unix server.
when I try to give in something like :
Code: Select all
<?php
$main_query = "INSERT INTO submitted_material_list
(Application_Material_ID,
Application_ID,
Physical_Copy,
Rec_By,
Rec_Date)
VALUES ($app_mat_id,
$app_id,
load_file('check/$_FILES['userfile']['name']'),
$app_id,
SYSDATE)";
?>
It gives me syntax / parse error on load_file()
Can anyone please help me out with this !!
Thanks in advance
-
nigma
- DevNet Resident
- Posts: 1094
- Joined: Sat Jan 25, 2003 1:49 am
Post
by nigma »
Maybe
Code: Select all
<?php
$main_query = "INSERT INTO submitted_material_list
(Application_Material_ID,
Application_ID,
Physical_Copy,
Rec_By,
Rec_Date)
VALUES ($app_mat_id,
$app_id,
load_file("check/$_FILESї'userfile']ї'name']"),
$app_id,
SYSDATE)";
?>
If that doesn't work please let me know.
-
twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Post
by twigletmac »
The problem is that array within the double quotes, for example,
Code: Select all
$string = "blah $array['element'] blah";
will give a parse error, whereas
Code: Select all
$string = "blah {$array['element']} blah";
or
Code: Select all
$string = "blah $array[element] blah";
won't.
Mac
-
devork
- Forum Contributor
- Posts: 213
- Joined: Fri Aug 08, 2003 6:44 am
- Location: p(h) developer's network
Post
by devork »
why don't you upload the files to secure directory and store their paths in database ?
-
nigma
- DevNet Resident
- Posts: 1094
- Joined: Sat Jan 25, 2003 1:49 am
Post
by nigma »
Hey twig, thanks for saving my ass on that one, I shouldn't have answered the question if I wasn't 100% sure of my answer.
-
devork
- Forum Contributor
- Posts: 213
- Joined: Fri Aug 08, 2003 6:44 am
- Location: p(h) developer's network
Post
by devork »
nigma ?
-
nirma78
- Forum Commoner
- Posts: 42
- Joined: Wed Sep 17, 2003 2:02 pm
Post
by nirma78 »
hey guys thanks for your reply !!
I tried doing
Code: Select all
<?php
$main_query = "INSERT INTO submitted_material_list
(Application_Material_ID,
Application_ID,
Physical_Copy,
Rec_By,
Rec_Date)
VALUES (1,
$app_id,
load_file("check/{$_FILES['userfile']['name']}"),
$app_id,
SYSDATE)";
?>
$result = $db->Execute($main_query) or die($db->ErrorMsg());
I tried :
Code: Select all
<?php
load_file("check/$_FILES['userfile']['name']")
load_file("check/$_FILES[userfile][name]}")
load_file("check/{$_FILES['userfile']['name']}")
?>
BUT IT STILL GIVES ME ERROR - PARSE ERROR on load_file()
PLEASE HELP ....
Thanks in advance
-
twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Post
by twigletmac »
You need to change:
Code: Select all
"check/{$_FILES['userfile']['name']}"
to
Code: Select all
'check/{$_FILES['userfile']['name']}'
it's the double quotes within double quotes causing the problem.
Mac
-
nirma78
- Forum Commoner
- Posts: 42
- Joined: Wed Sep 17, 2003 2:02 pm
Post
by nirma78 »
Thanks for the reply.
I changed my code as :
Code: Select all
<?php
load_file('check/{$_FILES['userfile']['name']}')
?>
so now the error has changed. It gives me the below error :
ORA-00904: "LOAD_FILE": invalid identifier
So does this mean that LOAD_FILE is not supported in Oracle ??
Please help.
Thanks in advance
-
nirma78
- Forum Commoner
- Posts: 42
- Joined: Wed Sep 17, 2003 2:02 pm
Post
by nirma78 »
I am running it from windows machine, having a unix server and Oracle 9i is the database...
Sorry if I didnt mention it earlier, I didnt know that this will affect my question anywhere..
So if LOAD_FILE is not supported in Oracle, how can I get it done ?? Is there a way to do it or not ??
Thanks