This has been asked a lot, a lot of posts in the imagesearch thread, and hundreds of posts on other forums. If (IsArray($result) = False) Then Return 0 Just check to see if it is an array