I have the following code that I am using to check for constraints on a database(for a class). U am trying to get the number of rows returned by the query and I keep getting the same error on the line
$count1= $ires1->numRows(MDB2_FETCHMODE_ASSOC);
Error:
> Call to a member function numRows() on a non-object
I've been pulling my hair out because my other functions similar to this one work fine, this is the only function that doesn't work. Is there something that stands out in this one?
The argument $db is just the connection to my database, pno
is an integer and the essn
is text.. So I'm not sure what I am doing wrong..
<?php
function submitCheck($db){
$essn= $_POST['essn'];
$pno=$_POST['pno'];
$query1 = "select * from works_on where pno=? and essn=?";
$types1 = array('integer','text');
$stmt1 = $db->prepare($query1, $types1, MDB2_PREPARE_MANIP);
if (MDB2::isError($stmt1)) {
print("bad prepared statement:" . $stmt->getMessage());
}
$queryargs1 = array($pno, $essn);
$ires1 = $stmt1->execute($queryargs1);
$count1= $ires1->numRows(MDB2_FETCHMODE_ASSOC);
//print("The project number entered was $count1[pno]");
if(!(count($count1)==0)){
print("The employee is already part of this project! If you want to update the hours, please select update!");
return false;
}
return true;
}
?>