I don't really see the need to pull out the offset to a different variable. The problem here is you are trying to pass an object to the sql string which doesn't appear to have a way to interpret it properly. My expectation is that the echo also will not work, but PHP's toString is flaky over different versions for where it is interpreted. If it shows properly within the echo, you can force the __toString() call on it to return the string representation.
Consult the documentation for the simple_html_dom_node to see what you need to do to extract it out of there.