Well, the problem is that SCRIPT_FILENAME just contains the path to the script, it doesn't contain anything after it.
So, something like this:
https://www.ubbcentral.com/forums/ubbthreads.php/ubb/showflat/Number/216111SCRIPT_FILENAME only contains:
https://www.ubbcentral.com/forums/ubbthreads.php/ubb/showflatIt chops off the actual data that we need to know what topic to show.