0

I want to get sum value of "number_of_date" in emp_leaves table, according to particular employee ID and make some variable to assign it's value. Following is my query.

 $resultOfcount= mysql_query("SELECT SUM(number_of_date) AS number_of_date FROM emp_leaves WHERE emp_id='$userID' && leave_category='$category");
             $value=mysql_fetch_array($resultOfcount);

             $value1=$value['number_of_date'];

But it makes some error which is

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in ..

How can I fix it, Please help.

Chathurika
  • 311
  • 2
  • 5
  • 18

1 Answers1

1

You are missing a ' at the end of the WHERE part

$resultOfcount= mysql_query("SELECT SUM(number_of_date) AS number_of_date FROM emp_leaves WHERE emp_id='$userID' && leave_category='$category'");

Thatswhy the query fails and returns false

marc_s
  • 704,970
  • 168
  • 1,303
  • 1,425
Fabian N.
  • 3,720
  • 2
  • 21
  • 45