Have you tried echo'ing out your query to make sure it looks correct? Though it probably works, referencing an array item as you did is definitely not the correct way. Not only should you not reference an array item inside a string without braces or closing the string, but array indeces are strings, which have quotes. Without the quotes for the key name, you're telling PHP that the key name is a constant, which I am 99% certain you are not intending to use.
Normally, I just close the string and concatenate the array piece in the middle (using periods) like so:
echo 'This is an example of an ' . $array['piece'] . '!!!';