MySQL fetching results nothing but query works fine in Mysql workbench:
$sql1="set @num := 0, @type := '';
select sum(t1.amount)as total_bal from (select cat1.customer_account_num, cat1.amount, @num := if(@type = cat1.customer_account_num, @num + 1, 1) as row_number, @type := cat1.customer_account_num as dummy,cat1.date_of_transaction from customer_account_transaction AS cat1, customer_account AS a, plan AS p where cat1.customer_account_num=a.customer_account_num and a.planid=p.planid and p.plantype=1 and a.executive='AV/E105' order by cat1.customer_account_num, cat1.date_of_transaction asc) as t1 where t1.row_number>1 and t1.date_of_transaction BETWEEN '2014-04-06' AND '2014-05-10';";
$result1=mysqli_query($GLOBALS['con'],$sql1);
$daily_bal='';
if($result1)
{
$row1=mysqli_fetch_array($result1);
$daily_bal=$row1['total_bal'];
echo $daily_bal;
}
mysql_query(...) or die(mysql_error());so you get an error.mysqli_multi_query()since your query is multi-statmentmysqli_query... look into mysqli_multi_query