Actually that query is located in two files adm-photo.php and editphoto.php both editing a photo.
I dont know why you would get that error as $puserid is clearly defined on deleting a photo but you can change the query in those two files as noted here to encapsulate the variable
Code:
Content visible to verified customers only.