9
The php code for XoopsCare runs independent of XOOPS, so I don't see how you would expect to access the XOOPS variables.
Doing a brief look at your code, I would suggest that you just re-write the code in SQL and use that part of XoopsCare instead. The tool works and can run the various pieces of code, but best I can tell it runs outside of the XOOPS environment because it's called by the account on the server under a cron job.
So, for MySQL, if you can successfully run the commands in phpMyAdmin for your XOOPS database, then you'll be able to run the same code inside this module.
Same for php. If you can run it from the command line as the user that will run the cron job, then XoopsCare will run it.
Clear as mud?