Welcome Guest, Not a member yet? Register   Sign In
Implode on Debian does not work anymore!
#1

[eluser]murphy2006[/eluser]
Hello!

I recently changed webserver OS from CentOS to Debian.
I am now having problems with parts of my code. The implode function does not work anymore. It worked fine on CentOS and on my local PC (Windows).

I got a webpage that contains alot of checkboxes so that users can make multiple choices and then the form is sent to a controller which implodes all the checkboxes into a comma seperated list of choosen items.

View file

The actual file contains many of the below form items (with different Values).

Code:
<input type="checkbox" class="checkbox" name="profile_marital[]" id="profile_marital[]" value="1" />

Controller file

Code:
implode(',', $this->input->post('profile_marital', TRUE));

I have also tried this but it failed too:

Code:
implode(',', $this->input->post('profile_marital[]', TRUE));

The error

Code:
A PHP Error was encountered

Severity: Warning

Message: implode() [function.implode]: Invalid arguments passed

Filename: models/profiles_model.php

Line Number: 1023

Does anyone know what is wrong? The one thing I can think of is that CentOS used PHP 5.3 but Debian only 5.2.x

Please help!

Kind Regards,
Daniel
#2

[eluser]@rno[/eluser]
Hi Daniel,

I don't know what's wrong with your implode function call, but thought there might be an easier whay to get the values of you checkboxes.
Why nog giving your checkboxes a name like: profile_marital[1] profile_marital[2] etc.

Once in your controller you could loop through the checkboxes as an array:

Code:
$items = $this->input->post('profile_marital');
if (count($items) > 0)
{
    foreach ($items as $item)
    {
        /* DO YOUR THING */
    }
}

Hope this helps.

Regards,
Arno




Theme © iAndrew 2016 - Forum software by © MyBB