Can anyone see what's wrong with this function? Running the query directly in MySQL produces correct results (ie a value for free and total_entitlement).
function Count_licenses($sID)
{
global $adb,$bgcl,$bgcd, $free;
$query = "SELECT * FROM software_licenses WHERE (sID = '$sID')";
$sth = $adb->prepare($query);
if($sth)
{
$res = $sth->execute();
$numRows = $sth->rows();
$record = $sth->fetchrow_hash();
$free = $record[free];
if($free = "No" || $free = ""){
$total_entitlement=0;
for ($i=0;$i<$numRows;$i++) {
$record = $sth->fetchrow_hash();
$total_entitlement+= $record[entitlement];
}
}else {
$total_entitlement = "Not applicable";
}
$sth->finish();
} else
{
PRINT "Could not prepare query: ".$sth->errstr."<BR>\n";
}
return $total_entitlement;
}
/M.
--
Martin Skjöldebrand
Family site: http://www.skjoldebrand.org
"Art" site: http://martoni.deviantart.com
Public key available at: http://wwwkeys.pgp.net