You may be able to give them ftp access to specific folders but in their code when they want db access they have to call an "external" script.
example
on my site I have
/www/virtual/myaccount/htdocs/index.php
but my database setup is at
/www/virtual/myaccount/includes/dbstuff.php
now, anyone with a browser can get to the first page and any file there but noone can get to the includes folder unless they are using a script on the server.
So, if your users had to
include('/www/virtual/myaccount/includes/dbstuff.php');
then they'd still get the database but not the passwords etc.
-- make sure you don't put the username and password in variables or they will be able to echo them out.