Re: Wow, this is weird

tamouse mailing lists <[email protected]>
Newsgroups gmane.comp.php.database
Message-ID <CAHUC_t-fyM8LD6kBzbqhn9KCS9TVzicryU72dM1xcQ4Jv9Qeig@mail.gmail.com>
On Tue, Aug 28, 2012 at 6:12 AM, David McGlone <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.