I have read up on doing this, and actually implemented this, for v1.5 but will like some help on v1.6+.
v1.5 samples: http://forum.joomla.org/viewtopic.php?p=1559295
This is a follow on to my query here: Joomla 1.6 External PHP Interaction Issue which got no response ... maybe a bit too long and rambling.
Thanks for any help given.
Starting with Joomla 1.6 the CMS is separated from the underlying Joomla platform, therefore you should look into using the Joomla platform to be able to use for example the database connector.
Here are some examples: How to create a stand-alone application using the Joomla! Platform