I am using SQLSRV 3.0 for PHP and working against a MSSQL2008.
My problem I am having, is that I can't get a LIKE statement in the query to work?
$connectionOptions = array( "Database"=>$myDB, "UID"=>$myUser, "PWD"=>$myPass);
$conn = sqlsrv_connect( $myServer, $connectionOptions);
$params = array(
"$sID%",
"$sUser%"
);
$sql = "select * from tbl where col2 LIKE ? or col2 LIKE ?";
$stmt = sqlsrv_query($conn, $sql, $params);
if( $stmt === false) {
die( print_r( sqlsrv_errors(), true) );
}
The problem is related to the design of the items in the params array, any suggestion?
Regards, Jakim
Adjust your code to the following:
Try to do this: