I’m trying to save to a db, and I need to implement a system in which users can specify in which fields of a given table the data has to be saved.
During my tests I had tried the following and everything worked fine:
$v = $rowdata; // array with the data to be saved
$r = "field1,field2,field3"; // fields of the table in which to save
Then I prepared the array with the names of the fields and I have put it in the former structure:
$v = $rowdata; // data to be saved
$r = $tablefields; // fields of the table to populate
But then I get the following message:
Column count doesn't match value count at row 1
I checked with print_r and the two arrays ($rowdata and $tablefields) have the exact same number of elements.
Any idea of why I’m getting this error?
you need to use implode function in php: