Validation Callback function not working - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Validation Callback function not working (/showthread.php?tid=44384) Pages:
1
2
|
Validation Callback function not working - El Forum - 08-12-2011 [eluser]terry101[/eluser] I currently worked on building verification using the callback function. For some reason the callback function isn’t working. Other verification functions work. “dbcheck” is the function which isn’t working on the script below. I dont get any errors either. Controller Code: function register(){ Validation Callback function not working - El Forum - 08-12-2011 [eluser]Mirge[/eluser] What do you mean by "doesn't work"? No error messages... is the function being called (dbcheck)? Have you verified it's being called? Is this code in a controller or model? More information please. Validation Callback function not working - El Forum - 08-12-2011 [eluser]terry101[/eluser] the function is in controller. yes its the function called dbcheck. i dont get any error, but i tested it and when inserting the same username from the one which is already in the database it doesnt give me a error and it would insert that username. Controller (the function on the controller called dbcheck, i added dbcheck in the validation for username) Code: function register(){ Validation Callback function not working - El Forum - 08-12-2011 [eluser]Mirge[/eluser] num_rows is a method, not a property. Change $verifyusername->num_rows to $verifyusername->num_rows() It should read: Code: if($verifyusername->num_rows()) { ... username already exists code here ... } Validation Callback function not working - El Forum - 08-12-2011 [eluser]terry101[/eluser] i tried that, still have the same problem Controller Code: function dbcheck ($username) { Validation Callback function not working - El Forum - 08-12-2011 [eluser]jblack199[/eluser] try your sql in a different way... Code: $this->db->where('username', $username); and see what comes of that... Validation Callback function not working - El Forum - 08-12-2011 [eluser]Mirge[/eluser] echo $verifyusername->num_rows().. make sure the value IS actually "1". I purposely left off the "==1" part. Validation Callback function not working - El Forum - 08-12-2011 [eluser]terry101[/eluser] jblack199 i tried what you suggested but no dice. Mirge the 1 was always included and no dice either. Any other suggestions on what could be possibly wrong? Code: function dbcheck ($username) { i tried var_dump($verifyusername); and i get nothin below, so nothing getting passes? object(CI_DB_mysql_result)[17] public 'conn_id' => resource(29, mysql link persistent) public 'result_id' => resource(34, mysql result) public 'result_array' => array empty public 'result_object' => array empty public 'custom_result_object' => array empty public 'current_row' => int 0 public 'num_rows' => int 16 public 'row_data' => null Validation Callback function not working - El Forum - 08-12-2011 [eluser]jblack199[/eluser] i've never been a fan of var_dump try: Code: echo "<pre>"; I think it puts it into an easier to read fashion... and you've echo'd out $verifyusername->num_rows() and checked to see what it returns but try changing $verifyusername->num_rows to $verifyusername->count_all('tbregister') and see if that fixes it... Validation Callback function not working - El Forum - 08-13-2011 [eluser]terry101[/eluser] I have tried Code: echo "<pre>"; Code: $verifyusername->count_all(‘tbregister’) |