I am trying to simple insert comma separated value in table field.But I don't get any cause why it's not working.
<?php
$array = array('1', '2', '3');
$comma_separated = implode(",", $array);
echo $comma_separated;
$sql = "INSERT INTO like(user_id,like_data)
VALUES ('1','$comma_separated')";
if ($connection->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $connection->error;
}
?>
Here like_data field I have taken varchar.
It is giving sql syntax error.