I’m getting an odd error when attemping to pass an array to a function which updates data in a MySQL table.
My trigger
$input_data = array(
'field0' => 'abc',
'field1' => '123'
);
// var dump #1
var_dump($input_data);
// gives expected result (2 element array)
$this->user->update_user_info($input_data);
User model
function update_user_info($new_data) {
// var dump #2
var_dump($new_data);
// this gives:
// array(2) {
// ["field0"] => string(3) "abc"
// ["field1"]=> string(3) "123"
// }
// NULL
}
Where is that ending NULL coming from?? I am trying to use this with Codeigniter’s active Record Update class and it fails because of that NULL.
I’ve attempted to copy it to a new array by looping through a foreach, but the NULL value follows to the new array, even though it doesn’t appear to be in the array.
Any help would be appreciated.
Apologies for the above ‘Answer’, I’m new to the site and couldn’t see the comment button :p
I’ve since solved this problem in terms of my own circumstances and possibly this may apply to you.
As I said earlier my problem was identical, the cause was not correctly returning both functions – I returned the secondary function i.e the one that my array was passed to like so.
but in the first function I was not returning after calling the second function, hope that makes sense and that this helps you too, it was frustrating as hell for me!