Mufleeh Posted July 13, 2011 Share Posted July 13, 2011 Hi, I need the count of the retrieved results from my data base. Below coding isn't working can anyone fix this to me? $queryMe = $this->dbh->prepare("SELECT name_initials FROM view_teachers_information WHERE nic IN (SELECT nic FROM view_teachers_current_school_appointment WHERE appointment_category_name = 'Mathematics' AND census_id IN (SELECT census_id FROM view_schools WHERE division_id = '$div[division_id]'))"); $queryMe->execute(); $countMe = $queryMe->fetchall(); $result = count($countMe); echo $result; Regards, Mufleeh Link to comment https://forums.phpfreaks.com/topic/241871-count-of-an-array/ Share on other sites More sharing options...
Adam Posted July 13, 2011 Share Posted July 13, 2011 Looks like you're using PDO. Check if ->errorInfo() contains an error that might explain the problem. Link to comment https://forums.phpfreaks.com/topic/241871-count-of-an-array/#findComment-1242123 Share on other sites More sharing options...
Mufleeh Posted July 13, 2011 Author Share Posted July 13, 2011 Hi, It displays below error, Array ( [0] => 00000 [1] => [2] => ) 0Array ( [0] => 00000 [1] => [2] => ) 0Array ( [0] => 00000 [1] => [2] => ) 0Array ( [0] => 00000 [1] => [2] => ) 0 Link to comment https://forums.phpfreaks.com/topic/241871-count-of-an-array/#findComment-1242150 Share on other sites More sharing options...
Adam Posted July 13, 2011 Share Posted July 13, 2011 Did you call it for PDO or PDOStatement ? Link to comment https://forums.phpfreaks.com/topic/241871-count-of-an-array/#findComment-1242280 Share on other sites More sharing options...
Mufleeh Posted July 13, 2011 Author Share Posted July 13, 2011 Did you call it for PDO or PDOStatement ? Hi, I am sorry, I can not exactly understand what do you mean. I receive the above thing when I used ->errorInfo() in my coding. This is how I used it. print_r($this->dbh->errorInfo()); Regards, Mufleeh Link to comment https://forums.phpfreaks.com/topic/241871-count-of-an-array/#findComment-1242290 Share on other sites More sharing options...
Adam Posted July 13, 2011 Share Posted July 13, 2011 Did you call it through PDO (accessed using $this->dbh in your code), or through PDOStatement (accessed using $statement in your code)? Both have a method called errorInfo(), but since you're using a statement I believe the error will only be available in the statement object. Link to comment https://forums.phpfreaks.com/topic/241871-count-of-an-array/#findComment-1242296 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.