validation php error with falidation fails |
[eluser]allibubba[/eluser]
hello there, been working woth codeigniter for a little while, trying to convert a previous site over to run the CI framework, so far i'm loving it, it's simple and intuitive, and so far have been able to overcome most of my problems, but this one has me a but confused. here goes, i have a form with validation in my controller. my validation works great, returns correct error messages relevant to post parameters. the problem though, when validation does fail, i get my error messages, but i also get these two injected into my page: A PHP Error was encountered Severity: 4096 Message: Object of class CI_DB_mysql_result could not be converted to string Filename: libraries/Validation.php Line Number: 195 and A PHP Error was encountered Severity: Notice Message: Object of class CI_DB_mysql_result to string conversion Filename: libraries/Validation.php Line Number: 195 i took a look at Validation.php: line 195 : $ex = explode('|', $rules); but when looking back through my controller i don't see any pipe problems? here's my validation Code: $data['name'] = "required|min_length[5]|max_length[125]"; any help or ideas would be great
[eluser]Sarfaraz Momin[/eluser]
I see some callbacks there. This would not help can you paste the callback functions also and also what is line 195.
[eluser]dbashyal[/eluser]
probably variable name error $data inplace of $rules validation looking for $rules did u call set rules like this Code: $this->validation->set_rules($rules); Code: $this->validation->set_rules($data); i guess you have to pass $data i.e. 2nd one
[eluser]allibubba[/eluser]
thanks for taking a look at this, i still haven't figured this out yet though... here's line 195 from Validation.php Quote:line 195 : $ex = explode(’|’, $rules);which i then looked into my rules to see if i had missed any pipes and joined two rules, but they are all there and rules are set with $data Code: $this->validation->set_rules($data); here's my validation check Code: //set validation error output as for the callbacks, they all appear to be working, but here they are jsut in case i'm missing anything: Code: function email_check($str){ also, quick sub question. does this look like the best way to be validation these form fields, with several callbacks, or should i combine my callbacks into one function, and only have a callback on my last input? thanks for the help so far.
[eluser]Nikhil Vijayan[/eluser]
Change these lines in login_check callback Code: $data['query'] = $this->db->get('users'); To this Code: $query = $this->db->get('users');
[eluser]dbashyal[/eluser]
am in a hurry but saw one spell mistake in rules, 'passwordconfirm' (m|n) that may not be the cause. will see it 2moro after work.
[eluser]allibubba[/eluser]
Nikhil, thanks for the suggestion, updated my code, but no luck. dbashyal, yeah, i caught that after i posted. i've since commented out all validation except for my first field; Code: $data['name'] = "required|min_length[5]|max_length[125]"; now, i can submit fine if i meet those requirements, (5 to 125 characters). but if i fail my validation i still get that php error. starting to wonder if it is normal and if i had error reporting off i would not have the problem, but that doesn't seem right either, if validation fails i should just return to my registration form with error messages displayed, right? here's my failure statement; Code: //set validation error output
[eluser]Nikhil Vijayan[/eluser]
you have pointed the error is at this line Code: $ex = explode('|', $rules); so in validation library above this code just add this Code: var_dump($rules); and let me know whats the output when you are getting the error Also what i understand is you are passing a mysql result into it somehow.. ..
[eluser]allibubba[/eluser]
when i get home from work i'll put the whole page up, see if there is anything i'm missing, and i'll run var_dump(), see what i get from that as well.
[eluser]allibubba[/eluser]
here's what i get from the dump; Code: string(4) "form" string(4) "FORM" string(7) "contact" object(CI_DB_mysql_result)#15 (7) { ["conn_id"]=> resource(28) of type (mysql link persistent) ["result_id"]=> resource(36) of type (mysql result) ["result_array"]=> array(0) { } ["result_object"]=> array(0) { } ["current_row"]=> int(0) ["num_rows"]=> int(1) ["row_data"]=> NULL } i've posted my entire contact controller (should actually be registration, but change that later) contact controller view source of page to see formatted php. again, thanks for any help or ideas |
Welcome Guest, Not a member yet? Register Sign In |