[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-db
Subject:    Re: [PHP-DB] Wow, this is weird
From:       tamouse mailing lists <tamouse.lists () gmail ! com>
Date:       2012-08-29 18:33:20
Message-ID: CAHUC_t-fyM8LD6kBzbqhn9KCS9TVzicryU72dM1xcQ4Jv9Qeig () mail ! gmail ! com
[Download RAW message or body]

On Tue, Aug 28, 2012 at 6:12 AM, David McGlone <david@dmcentral.net> wrote:
> On Tuesday, August 28, 2012 12:41:19 AM you wrote:
>> Here, in your original pastebin, at line 36:
>>
>> mysql_query ("INSERT INTO inventory(image, year, make, model, milage, price)
>> VALUES('$_POST[image]', '$_POST[year]', '$_POST[make]',
>> '$_POST[model]', '$_POST[milage]', '$_POST[price]')");
>>
>> should be:
>>
>> mysql_query ("INSERT INTO inventory(image, year, make, model, milage, price)
>> VALUES('{$_FILES['image']['name']}', '$_POST[year]', '$_POST[make]',
>> '$_POST[model]', '$_POST[milage]', '$_POST[price]')");
>
> This method was tried, and didn't work, it was inserting "Array[name]" into
> the db. This method was also what made me realize that $_FILES['image']
> ['name'] is being interpreted as an array. So what I did was assigned the
> value to a variable.

I think you must be missing the '{}' brackets, or something, because
with this added to the snippet from before:

$sql = "INSERT INTO inventory(image, year)
VALUES('{$_FILES['image']['name']}', '$_POST[year]')";
echo '<h2>$sql = </h2><pre>'.PHP_EOL;
var_dump($sql);
echo '</pre>'.PHP_EOL;

I get:

$sql =

string(58) "INSERT INTO inventory(image, year) VALUES('1.png', '2012')"

which shows $_FILES['image']['name'] correctly interpolated to a string.

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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic