vendredi 17 juin 2016

PHP seems to add in backslashes when strings are concatenated

I am creating a query where I am passing in parameters and when the string query is concatenated, there are backslashes which are added and this makes the query not run worthy.

 $searchQuery = "Select * from  <table_name> where Department like
 '".$department. "' and Purchaser_Name like '%".$purchaser. "%' and
 Vendor_Name like '%".$vendor. "%' and User_Name like '%".$requester.
 "%' and PS_Account like '%".$psaccount. "%' ;";

this above string is converted

"Select * from  [dbo].[Unicard_Transactions] where Department like  \'%staff%\'  and Purchaser_Name like \'%mordica%\' and Vendor_Name like \'%crucial%\' and User_Name like \'%reeves%\' and PS_Account like \'%739000%\' "

Would like to know how I can go about creating a search string without the slashes.

Aucun commentaire:

Enregistrer un commentaire