0

i have an array which come from form and i add commas between values with implode. But i have to add single quotes at start and end of values.

$form_values = $_GET['values'];
$sql.=" WHERE value IN (".implode(',',$form_values).")";

i use this query and it gives a result like that.

value1,value2,value3

and i use this values for my sql query. But i have to add single quotes also at start and end of these values. It must be like this;

'value1','value2','value3'

I really don't know how can i add these single quotes.

Nevzat Uz
  • 17
  • 1
  • 8
  • `$sql.=" WHERE value IN ('".implode('\',\'',$form_values)."')";` – Federkun Jun 20 '17 at 08:20
  • Learn about prepared Statements. It will prevent you from SQL injection and solve your problem – Jens Jun 20 '17 at 08:21
  • Federkun thanks for your help but i got this error implode(): Invalid arguments passed in. Is there any problem in the query you think? – Nevzat Uz Jun 20 '17 at 08:23

1 Answers1

0

Can you please try below.

$sql.=" WHERE value IN ("'"+".implode(',',$form_values).""'")";