% Operator in php

Sir I am using these codes with sqlserver

declare @f_date1 as date='2016-11-01' declare @groups as varchar(4)='1401' SELECT acc_code,open_dr as dr_amount,open_cr as cr_amount from master where acc_code like @groups+'%'

it work fine, but when i use with php query like this

[php]$groups=‘1401’;
$t_date1=date(‘Y-m-d’);
SELECT acc_code,dr_amount,cr_amount from vouchers where date <= ‘".$t_date1 ."’ and LEN(acc_code)>4 and acc_code like '".$groups."+%[/php]

then it says:

Warning: sqlsrv_errors() expects parameter 1 to be long, resource given in C:\wamp\www\atsql17_php\book_blance.php on line 370

the question is how to modify this line

[php]like '".$groups."+%[/php]

Please help

First use prepared statements. Second, what you showed isn’t the error you are facing. What is the actual code, not the sql statement.

The statement should be closer to:

[php]SELECT acc_code,dr_amount,cr_amount from vouchers where date <= ‘".$t_date1 ."’ and LEN(acc_code)>4 and acc_code like ‘".$groups."%’[/php]

Thanks sir done

Sponsor our Newsletter | Privacy Policy | Terms of Service