benphp Posted April 11, 2008 Share Posted April 11, 2008 I've been looking for a solution to this for hours - can someone help? I'm using MS Access as the db DSN-Less, and my SQL looks like this: function fnOpenDbConn() { $db_Conn = new COM("ADODB.Connection"); $db_connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=".$_SERVER['DOCUMENT_ROOT']."/Evaluation/db/eval.mdb;Uid=;Pwd=;DefaultDir=".$_SERVER['DOCUMENT_ROOT']."/Evaluation/db"; $db_Conn->open($db_connstr); return $db_Conn; } //end fnOpenDbConn $sqlc = "SELECT c_instructor FROM evaluations WHERE c_instructor = $pid "; $rSc = $dbConn->execute($sqlc); $rSc->Close(); $rSc = null; $dbConn->Close(); $dbConn = null; All I want to do is count the returned rows. I've tried this: $num_rows = $rSc->Fields->count(); which returns "1". and this: $num_rows = array($rSc); $num_rows = count($num_rows); which also returns "1". This would be easy in MySQL. Quote Link to comment Share on other sites More sharing options...
craygo Posted April 11, 2008 Share Posted April 11, 2008 looks like you are using some kind of class to do it. You would have to post the code for the class to help you out. Ray Quote Link to comment Share on other sites More sharing options...
benphp Posted April 11, 2008 Author Share Posted April 11, 2008 The code I posted does it all. function fnOpenDbConn() { $db_Conn = new COM("ADODB.Connection"); $db_connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=".$_SERVER['DOCUMENT_ROOT']."/Evaluation/db/eval.mdb;Uid=;Pwd=;DefaultDir=".$_SERVER['DOCUMENT_ROOT']."/Evaluation/db"; $db_Conn->open($db_connstr); return $db_Conn; } //end fnOpenDbConn $dbConn = fnOpenDbConn(); $sqlc = "SELECT c_instructor FROM evaluations WHERE c_instructor = $pid "; $rSc = $dbConn->execute($sqlc); $num_rows = $rSc->Fields->count(); print "$num_rows"; $rSc->Close(); $rSc = null; $dbConn->Close(); $dbConn = null; Quote Link to comment Share on other sites More sharing options...
craygo Posted April 11, 2008 Share Posted April 11, 2008 Well you have to be pointing somewhere to a class, either on another page or some include, because $rSc don't exist on its own. I see $dbConn in your script here but not $rSc. Ray Quote Link to comment 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.