BuildMyWeb Posted December 4, 2014 Share Posted December 4, 2014 function chk_error($site_mode, $obj) { if( $site_mode == 'dev' ) { echo'Error : ('. $obj->errno .') '. $obj->error; } } chk_error($site_mode, $stmt); the above is not working for me. it echos out the text but no values for errno and error. what am i doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/292899-passing-object-as-arg-to-function/ Share on other sites More sharing options...
Solution Psycho Posted December 4, 2014 Solution Share Posted December 4, 2014 Have you verified that $stmt is an object and that it has properties for errno and error before you pass it to the function? function chk_error($site_mode, $obj) { if( $site_mode == 'dev' ) { echo'Error : ('. $obj->errno .') '. $obj->error; } } var_dump($stmt); //Let't verify what $stmt is and what it contains chk_error($site_mode, $stmt); Quote Link to comment https://forums.phpfreaks.com/topic/292899-passing-object-as-arg-to-function/#findComment-1498550 Share on other sites More sharing options...
maxxd Posted December 4, 2014 Share Posted December 4, 2014 Is $site_mode set to 'dev' and does the $statement object have values for the errno and error properties? Or is there something more specific you can tell us about how it's not working? Quote Link to comment https://forums.phpfreaks.com/topic/292899-passing-object-as-arg-to-function/#findComment-1498551 Share on other sites More sharing options...
BuildMyWeb Posted December 4, 2014 Author Share Posted December 4, 2014 dammit. passing the wrong object. thanks Psycho. Quote Link to comment https://forums.phpfreaks.com/topic/292899-passing-object-as-arg-to-function/#findComment-1498555 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.