I have a large lump of code that outputs a custom table for my blog. This used two database calls, one $wpdb->get var and one get_results.
After getting a few queries I was thinking about formatting this up into a plugin. The firs thing I did was to take the perfectly functioning code, put it in a function and call it immidietly afterwards to make sure it was ok. No such luck, failed dead without even an error. After some messing around I worked out it was the db calls that were now failing spectacularly. Why is it when i put those db calls in a function they fail? How do I get around this? What am i doing wrong?