Need help related to my codeigniter wallpaper script |
(01-12-2018, 05:02 AM)jreklund Wrote:(01-12-2018, 04:02 AM)InsiteFX Wrote: GROUP BY should be the last statement in database queries.It's the last statement. Take note of the brackets. Thanks guys for your support, but didn't work. I added PHP Code: public function color_sql($filter) and returns I guess the same error: Code: A Database Error Occurred But, also wonder why the 1st color that not returns the error, why not return the wallpaper? (Why is coding so hard? Kidding! )
It's suppose to be before everything else, so that you dump what $filter holds. Now it's already returning the sql command.
PHP Code: public function color_sql($filter)
Yes, now returns this:
array(4) { ["saturation"]=> array(2) { [0]=> int(0) [1]=> int(40) } ["lightness"]=> array(2) { [0]=> int(0) [1]=> int(40) } ["hue"]=> array(2) { [0]=> int(0) [1]=> int(20) } ["focus"]=> array(3) { ["H"]=> int(0) ["S"]=> int(0) ["L"]=> int(0) } } You can test it, because I didn't remove it yet.
Try this one
PHP Code: public function color_sql($filter)
@jreklund
Thank you!!!! It works now. But, can you explain me a little detailed how it works exactly, because I don't really understand how is thought. Some colors from spectrum don't return any wallpaper. And some return only one (depends on how much it is in) which is correct and some returns both which is also correct. But why some colors that are listed don't return any wallpaper (why to be there if don't match any wallpaper)?
Everything looks good and well from these CI functions:
where -> _wh('qb_where') But when you are compiling it to pure SQL and validating against SQL injections: get_compiled_select (same as your sql I guess) -> _compile_select -> _compile_wh('qb_where') It separate everything and later on glues everything together. And in the process trims white space due to the fact 0 = empty. system\database\DB_query_builder.php LINE 2433: $conditions[$ci] = $matches[1].$this->protect_identifiers(trim($matches[2])) LINE 2434: .' '.trim($matches[3]).$matches[4].$matches[5]; LINE 2437: $this->{$qb_key}[$i] = implode('', $conditions); So I disabled the sql injection protection and forced all $filter values to be float numbers. ___________________________________ I can't answer why some colors works but some dosen't. - You need to look on how these colors get generated. - How they are stored in the database. - How the select query works.
Hello again!
I need your help again. 1. First code: (this one is loaded in html too, of course without the php parts) PHP Code: <div class="col-sm-6"> 2. Second code: PHP Code: if ($this->form_validation->run() && empty($data['error']) && $data['image']) { Here in the 2nd code, at the "license" line I think it is the part that it writes in database the number that corresponds to selected license. But, it doesn't matter what license I choose, because always choose the one from the number 2. (i seen that '2' from the end, and i remove it that '2', the ':' ... all kind of trials... but when i remove it writes in database 0 or null. Is ) 3. Third code: PHP Code: if ($this->form_validation->run() && empty($data['error']) && $data['image']) { And in the 3rd code, if I update the wallpaper and choose another license don't change it. Can someone tell me what is wrong? (I think it is related to that "2" from the end, but I don't know how to tell it to write in database the new number that corresponds for the license set in the form_dropdown, because i choose another, in the form looks ok, but when i refresh the page or check the database is the same number set at first upload) Thank you! PS: Or maybe a simple way to write in database the number that I choose and which corresponds to the correct license.
You are opening a dropdown named 'license_type':
PHP Code: form_dropdown('license_type',array()); And later on you are trying to fetch a 'license' that's supposed to be 'license_type'. Also you need a haystack in your in_array. in_array validates your post (license_type) and try to match it against a haystack. haystack = all possible options. http://php.net/manual/en/function.in-array.php PHP Code: 'license' => in_array($this->input->post('license_type')) ? $this->input->post('license') : '2', PHP Code: $haystack = (1,2,3,4,5,6); // Don't hardcode this if you have an array already |
Welcome Guest, Not a member yet? Register Sign In |