I also have the data saved in another DB with the function 'DB Save'.Both functions work but only when the other one is disabled. When both are enabled I receive the error: 1054 - Unknown column 'Array' in 'field list' SQL=INSERT INTO `hyn4b_Koper-ID` (`Koper-ID`, `0`) values ('123456', Array);I also submitted a screenshot of my Setup.What can possibly went wrong?Thanks in advance"> 1054 - Unknown column 'Array' when saving to DB - Forums

Forums

1054 - Unknown column 'Array' when saving to DB

Tarrel 04 Dec, 2015
Hi,

I have a very simple form, with a Name, E-mail and Koper-ID as 'Text-Fields'.
On Submit there is a 'DB Read' to check the field 'Koper-ID' with value in a table with this function:
<?php
 return array("Koper-ID" => $form->data("Koper-ID")); ?>


I also have the data saved in another DB with the function 'DB Save'.

Both functions work but only when the other one is disabled. When both are enabled I receive the error:
1054 - Unknown column 'Array' in 'field list' SQL=INSERT INTO `hyn4b_Koper-ID` (`Koper-ID`, `0`) values ('123456', Array);

I also submitted a screenshot of my Setup.

What can possibly went wrong?
Thanks in advance
GreyHead 04 Dec, 2015
Hi Tarrel,

That needs to be $form->data["Koper-ID"] with [] instead of ()

Bob
Tarrel 04 Dec, 2015
Hi Greyhead,

Thanks for your answer, I changed it to
<?php
 return array("Koper-ID" => $form->data["Koper-ID"]); ?>


But still receive this error:
1054 - Unknown column 'Array' in 'field list' SQL=INSERT INTO `hyn4b_Koper-ID` (`Koper-ID`, `0`) values ('123456', Array);
GreyHead 04 Dec, 2015
Hi Tarrel,

Please drag a Debugger action into the On Submit event, then submit the form and post the debug results here.

Note: if you are using the Easy Wizard you can turn on Debug on the Others tab in CFv4 or the Setup tab in CFv5.

Bob
Tarrel 04 Dec, 2015
Hi Greyhead,

After adding the debugger nothing changes, still the same error and nothing else, no debug info.
I've added the screenshot of the error.
GreyHead 05 Dec, 2015
Hi Tarrel,

Please disable the DB Save temporarily and try again - you should see the Debugger output then. There is something odd with the data as you are trying to save to a column name 0 - which isn't a valid column name.

Bob
Tarrel 05 Dec, 2015
Hi GreyHead,

This is the debug info when the DB Save is disabled.

Data Array

Array
(
    [option] => com_chronoforms5
    [chronoform] => dlb_Kaartverkoop_TEST1
    [event] => submit
    [Naam] => Niels
    [E-mail] => nvanlieshout@hotmail.com
    [Koper-ID] => 123456
    [Verzenden] => Verzenden
)

Array
(
)

Errors

Array
(
)

Debug Info

Array
(
)


And this when the DB Read is disabled.

Data Array

Array
(
    [option] => com_chronoforms5
    [chronoform] => dlb_Kaartverkoop_TEST1
    [event] => submit
    [Naam] => Niels
    [E-mail] => nvanlieshout@hotmail.com
    [Koper-ID] => 123456
    [Verzenden] => Verzenden
)

Array
(
)

Errors

Array
(
)

Debug Info

Array
(
)
GreyHead 06 Dec, 2015
Hi Tarrel,

They are both the same - is that correct - there is no Array there so I guess that one is wrong?

Bob
Tarrel 06 Dec, 2015
Hi GreyHead,

I've tried it again and the result is the same again, both the same text.
Earlier this year my Joomla website and database were moved to a new server, untill now everything worked OK but these forms react really weird.

Maybe I should just re-install Chronoforms again?

Thanks in advance
GreyHead 06 Dec, 2015
Hi Tarrel,

By all means PM me the site URL, the form name, and a SuperAdmin login and I'll take a quick look.

Bob
GreyHead 06 Dec, 2015
Hi Tarrel,

The reason why the DeBugger output is the same is that you had the Debugger at the start of the On Submit event. I've moved it to the end so that you can see the result of the other actions.

The DB Read is set to Multi so you get an array of results returned even if there is only one found. The output is like this
Array
(
    [option] => com_chronoforms5
    [chronoform] => dlb_Kaartverkoop_TEST1
    [event] => submit
    [Naam] => Bob Testing
    [E-mail] => test@example.com
    [Koper-ID] => 123456
    [Verzenden] => Verzenden
    [0] => Array
        (
            [Koper-ID] => 123456
        )

    [ip_address] => 86.999.999.12
)
That's where the array is coming from when you try to save this again.

I can't tell if the ID is supposed to be unique or not - if it is then turning off Multi in the DB Read will probably work OK. If not then you may need some Custom Code to clean up the results to save what you actually need.

Bob
This topic is locked and no more replies can be posted.