-3

I make a php page in which i want to get data from database but when i run it gives me the warning "mysql_num_rows() expects parameter 1 to be resource".

How i remove this warning?

Here is my code:

$strQuery1 = "select DATE_FORMAT(transactions.transaction_date,'%m-%d-%Y') as transaction_date,sum(amount)as Amount from transactions where event_id='7' group by  DATE_FORMAT(transactions.transaction_date,'%m-%d-%Y')";
$result1 = $GLOBALS ['mysqli']->query ($strQuery1) or die ($GLOBALS ['mysqli']->error . __LINE__);
$rows=mysql_num_rows($result1);
while($rs1=$result1->fetch_assoc()){    
    $res1[]=$rs1;                   
}
for ($i = 0 ; $i <=30 ; $i++) {
    foreach($res1 as $r){
        if($r['transaction_date']==$dates[$i]){
            $substrXML1= "<set value='" . $r['Amount'] ."' />";
            break;
        } else
           {
            $substrXML1= "<set value='0' />";
        }
    }
        $strXML1 .=$substrXML1;
}
    $strXML1.="</dataset>";
Muhammad Arif
  • 1,014
  • 3
  • 22
  • 56

2 Answers2

0
$rows=mysqli_num_rows($result1);
-2

May be this useful to you

$rows = mysql_num_rows($result1); //old
$rows = mysql_query($result1); //changed
while($rs1=mysql_fetch_array($rows))
or
while($rs1=$result1->fetch_assoc()){    
    $res1[]=$rs1;                   
}
Muhammad Arif
  • 1,014
  • 3
  • 22
  • 56
dev4092
  • 2,820
  • 1
  • 16
  • 15