Re: [PHP-DB] file upload array problem

2002-12-21 Thread Jason Wong
On Saturday 21 December 2002 05:25, Seabird wrote:
> Hi everyone,
>
> every time I try to upload a picture I get the same problem in return.
> First of all, it's not being uploaded (but this is for later concern I'm
> afraid). Trying to display the info of the (not)uploaded file should be
> done with:
>
> $_FILES['picture']['name']
>
> but every time I run this the return is a error like this:
>
> Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or
> `T_NUM_STRING' in c:\apache\htdocs\seabird.jmtech.ca\otf.com\submit.php on
> line 69

Which is line 69?

> If I leave out the qoutes it runs fine but my output (echo) is
> Array['name']
>
> Running a FILES list gives correct names and everything. Where did this go
> wrong??
>
> Here's my code aswell please help me, don't point me to another website
> or manual (have read a dozen, and I'm still stuck).
>
> if ($_POST[submit]) {

If you have error reporting set high enough you would have seen a warning 
about "Use of undefined constant submit...". You should use:

  if ($_POST['submit']) {

> $link = mysql_pconnect("localhost","myuser","mypass");
> $db = test;
> mysql_select_db($db,$link);
>
> $query = "INSERT INTO inventory
> (registration,type,total_time,price,description,picture_name)
> VALUES
> ('$_POST[registration]','$_POST[type]','$_POST[total_time]','$_POST[price]'
>, '$_POST[description]','$_FILES[picture]')";

If you're referring to array variables inside a double-quoted string you 
should enclose it within {}. Thus:

$query = "INSERT INTO inventory
(registration,type,total_time,price,description,picture_name)
VALUES
('{$_POST['registration']}','{$_POST['type']}',...)";

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *


/*
The keyboard isn't plugged in
*/


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




[PHP-DB] file upload array problem

2002-12-20 Thread Seabird
Hi everyone,

every time I try to upload a picture I get the same problem in return. First
of all, it's not being uploaded (but this is for later concern I'm afraid).
Trying to display the info of the (not)uploaded file should be done with:

$_FILES['picture']['name']

but every time I run this the return is a error like this:

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or
`T_NUM_STRING' in c:\apache\htdocs\seabird.jmtech.ca\otf.com\submit.php on
line 69

If I leave out the qoutes it runs fine but my output (echo) is Array['name']

Running a FILES list gives correct names and everything. Where did this go
wrong??

Here's my code aswell please help me, don't point me to another website
or manual (have read a dozen, and I'm still stuck).

if ($_POST[submit]) {

$link = mysql_pconnect("localhost","myuser","mypass");
$db = test;
mysql_select_db($db,$link);

$query = "INSERT INTO inventory
(registration,type,total_time,price,description,picture_name)
VALUES
('$_POST[registration]','$_POST[type]','$_POST[total_time]','$_POST[price]',
'$_POST[description]','$_FILES[picture]')";

exec("cp $_FILES[picture]
http://localhost/seabird.jmtech.ca/otf.com/images/$_FILES[picture][name]";);

mysql_query( $query, $link);
print 'Thank youYou have submitted the following information:';
echo "Registration: $_POST[registration]\n";
echo "Type: $_POST[type]\n";
echo "Total Time: $_POST[total_time]\n";
echo "Price: $_POST[price]\n";
echo "Description: $_POST[description]\n";
echo "temp file: $_FILES[picture]\n";
echo "file name: $_FILES[picture][name]\n";
echo "file size: $_FILES[picture][size]\n";
echo "file type: $_FILES[picture][type]\n";
echo "\n";
echo "\n";
}
else { ?>

  Registration


type


total time


price


Description


picture


  

";
print_r($_FILES);  // or use print_r($_POST) if you are using a POST instead
of a GET method for your form
echo "";
?>

--
http://seabird.jmtech.ca

Attitude is Everything!
But Remember, Attitudes are Contagious!
Is Yours worth Catching



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