Rewrite part of snapshot feature to get connections correctly

I've tried to minimize the amount of code I'm touching to complete this. I'd prefer not to rewrite the entire class.
How well will this handle errors/warnings etc that might end up in the code? You could put an echo newline before the phpcode, and then only capture the last line of output?