Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

SQLSRV_Query Syntax Help

$
0
0

Hello, I'm trying to create a web program that'll allow users to select multiple items, pick a date range, and then download a csv with the data that matches one of the selected reasons and falls within the date range. However, no matter what I try, I get "Incorrect syntax near $array" for the SQLSRV_Query.
Any help is appreciated

$array = $_POST['ubreasons'];
// Adding single quotes and comma separated into array
$array = implode(" ',' ", $array);
$array = " ' ".$array." ' ";

$searchQuery = sqlsrv_query($cxn, "SELECT Account, First_Name, Last_Name, SUM(ClaimLineBalance) AS CashValue
FROM v_UnBilledClaims_Report
WHERE UBReason IN ('$array') //Here is where the problem is
GROUP BY Account, First_Name, Last_Name
ORDER BY CashValue DESC");


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>