-1

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?

kann
  • 687
  • 10
  • 22
mirec
  • 147
  • 1
  • 1
  • 7
  • What is $accesToken and $reset_accesToken? – Wimanicesir Oct 27 '21 at 07:25
  • Check this one https://stackoverflow.com/questions/57336194/codeigniter-unknown-column-array-in-field-list; maybe it can help. – Mainul Hasan Oct 27 '21 at 07:32
  • 1
    "*Array to string conversion*" - one of the fields you are using in your query is actually an array, not a string. You need to find debug it and out which one. – Don't Panic Oct 27 '21 at 12:46
  • You should use prepared statements for SQL queries with variables, see https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php – Progman Dec 27 '21 at 13:14

1 Answers1

1

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.

sensorario
  • 20,262
  • 30
  • 97
  • 159