Home > Blockchain >  1054 Unknown column 'Array' in 'field list'
1054 Unknown column 'Array' in 'field list'

Time:10-27

Can someone help me with this error, when 1054 Unknown column 'Array' in 'field list'

[27-Oct-2021 09:15:04 Europe/Berlin] PHP Notice: Array to string conversion in C:\xampp\htdocs\joomla20\plugins\breezingforms_addons\gdata\gdata.php on line 398

the code is :

         $db->setQuery("Update #__breezingforms_addons_gdata Set
            `enabled`  = ".JRequest::getInt('gdata_enabled', 0).",
            ".($accessToken || $reset_accessToken ? "`password` = " . $db->quote($accessToken).',' : '')."
            `spreadsheet_id` = ".$db->quote(trim($gspid) == '' ? "''" : $gspid).",
            `worksheet_id` = ".$db->quote(trim($wid) == '' ? "''" : $wid).",
            `fields` = ".$db->quote($_POST['gdata_fields']).",
            `meta` = ".$db->quote($_POST['gdata_meta'])."
            ".($reset_accessToken ? ",`custom_client_id` = " . $db->quote("34263101371-4rcre0p6r9ehuhoat1d6ls8u84etuanp.apps.googleusercontent.com").', `custom_client_secret` = ' . $db->quote("IDq59sdLo6wC81KCUweDKVf2") : '')."
             Where form_id = " . intval($form_id) . "
        ");
        $db->query();
    }

the 398 line of code is :

    ".($accessToken || $reset_accessToken ? "`password` = " . $db->quote($accessToken).',' : '')."

What I do wrong?

Any help ?

CodePudding user response:

I think that I know what is a problem, in this code below:

"`password` = " . $db->quote($accessToken).',' : '')."

$accessToken is an array, not a string and it gives to me an error, and in the table of database in column "password" I can not see records!

But if I made string instead of array example: $accessToken="username->text, password->text"; -> I didn't got error and I can see records in my database.

while with array I got error:

$accessToken=array("username" => "text",
"password" => "text",); 

NOW is the question, how to store array type of data in a database? Any help?

CodePudding user response:

Cant store an array, but for example you can store an array, ...

$accessToken = array(
   "username" => "text",
   "password" => "text",
);

like a json, ...

$accessToken = json_encode(array(
   "username" => "text",
   "password" => "text",
));

The result is a string (or a json) and you can store it into a database.

  •  Tags:  
  • php
  • Related