[eluser]alvaroeesti[/eluser]
Hello
I have a Form and one of the controllers is a multiple select list. Alright, I add [ ] to the name of the control and it will keep the values selected alright, and it forwards them to the controller. So here start the problems
1. First the validation class, I basically have to remove all the validators because they can't digest an array, the trim had to be removed, the max length also, so..it could be abused if not sanitized
Code:
$this->form_validation->set_rules('cities', 'cities', 'xss_clean');
2. Then we want to grab those values from the multiple select list, to me more descriptive, I am actually keeping them in session variables
Code:
$cities[] = $this->getresults_m->cities_handler($this->input->get_post('cities', TRUE));
Alright, but now I have to pass that to the Model, and here is where the problems start
Severity: Notice
Message: Array to string conversion
Filename: database/DB_active_rec.php
A Database Error Occurred
Error Number: 1054
Unknown column 'Array' in 'where clause'
this "array" refers exactly to cities, because when I try to do
where city.id = $city instead of the variable it is the word Array that is standing on the right side of the equal.
So, actually in that array I will have several cities, then how am I going to put that into the sql query? it seems to me that I would have to loop through the array, getting one variable at the time and then running the full query each time for every variable?
thank you
regards