I'm using the following snippet to break up an string array, then insert them into the database.
//split tags into individual words
$tag_array = explode(',', $tags);
foreach($tag_array as $tag){
addslashes($tag);
echo $tag." ";
$addTagsQuery = "INSERT INTO `my_blog`.`tags` (`id`, `name`) VALUES
('".$id."', '".$tag."');";
$tagsResult = $db->query($addTagsQuery);
if($tagsResult){
echo "tag added <br />";
}
else {
echo "tag was not added <br />";
}
}
My problem lies within a scenario where multiple tag (strings) are submitted. Unfortunately, only the first string in the array is inserted. Any insight as to why only the first string in the array is inserted into the MySQL database would be appreciated.