Re: Wow, this is weird

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 28, 2012 at 6:12 AM, David McGlone <david@xxxxxxxxxxxxx> 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



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux