Re: If( Query)

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

 



all of us do, it's subscribed to the list. i filter it out.

On Mon, Sep 8, 2008 at 7:06 PM, Chris Hale <php@xxxxxxxxxxxxxxx> wrote:
> Evert Lammerts wrote:
>>
>> My bad! Forgot the dollar signs.... This should work:
>> function editproduct($item_id, $item_name, $item_desc, $item_price,
>> $item_pix, $item_man_id, $item_cat_id) {
>>        $item_id = mysql_real_escape_string($item_id);
>>        $item_name = mysql_real_escape_string($item_name);
>>        $item_desc = mysql_real_escape_string($item_desc);
>>        $item_price = mysql_real_escape_string($item_price);
>>        $item_pix = !empty($item_pix) ? mysql_real_escape_string($item_pix)
>> : null;
>>        $item_man_id = mysql_real_escape_string($item_man_id);
>>        $item_cat_id = mysql_real_escape_string($item_cat_id);
>>        connect();
>>        $sql = "UPDATE items SET item_name='{$item_name}',
>> item_desc='{$item_desc}', item_price='{$item_price}', " .
>> (!empty($item_pix) ? "item_pix='{$item_pix}', " : "") .
>> "item_man_id='{$item_man_id}', item_cat_id='{$item_cat_id}' WHERE
>> item_id={$item_id}";
>>        mysql_query($sql) or die('Insert failed: ' . mysql_error());
>> }
>>
>> On Mon, Sep 8, 2008 at 6:07 PM, Chris Hale <php@xxxxxxxxxxxxxxx> wrote:
>>
>>>
>>> Evert Lammerts wrote:
>>>
>>>>
>>>> Do a print on the query:
>>>>
>>>>
>>>>
>>>>>>
>>>>>> function editproduct($item_id, $item_name, $item_desc, $item_price,
>>>>>> $item_pix, $item_man_id, $item_cat_id) {
>>>>>>      $item_id = mysql_real_escape_string($item_id);
>>>>>>      $item_name = mysql_real_escape_string($item_name);
>>>>>>      $item_desc = mysql_real_escape_string($item_desc);
>>>>>>      $item_price = mysql_real_escape_string($item_price);
>>>>>>      $item_pix = !empty($item_pix) ?
>>>>>> mysql_real_escape_string($item_pix)
>>>>>> : null;
>>>>>>      $item_man_id = mysql_real_escape_string($item_man_id);
>>>>>>      $item_cat_id = mysql_real_escape_string($item_cat_id);
>>>>>>      connect();
>>>>>>      $sql = "UPDATE items SET item_name='{item_name}',
>>>>>> item_desc='{item_desc}', item_price='{item_price}', " .
>>>>>> (!empty($item_pix) ? "item_pix='{item_pix}', " : "") .
>>>>>> "item_man_id='{item_man_id}', item_cat_id='{item_cat_id}' WHERE
>>>>>> item_id={$item_id}";
>>>>>>
>>>>>>
>>>>
>>>>  var_dump($sql);
>>>>
>>>>
>>>>
>>>>>>
>>>>>>      mysql_query($sql) or die('Insert failed: ' . mysql_error());
>>>>>> }
>>>>>>
>>>>>>
>>>>
>>>>
>>>
>>> This is what i get:
>>>
>>> string(165) "UPDATE items SET item_name='{item_name}',
>>> item_desc='{item_desc}', item_price='{item_price}',
>>> item_man_id='{item_man_id}', item_cat_id='{item_cat_id}' WHERE item_id="
>>> Insert failed: You have an error in your SQL syntax; check the manual
>>> that
>>> corresponds to your MySQL server version for the right syntax to use near
>>> ''
>>> at line 3
>>>
>>>
>>>
>>>
>>
>>
>
> Thanks, seems to be working now.
>
> Also i meant to ask, does every one else get a foreign email from someone
> saying something about google groups every time they send ina new email to
>  this mailing list?
>

-- 
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