Jquery Mobile App connecting to a Database

Jquery Mobile App connecting to a Database

Dear All,
How can I make an installed JQM application that is installed on mobile phone connect to a mysql database. If I access the application via a website where I have hosted it, the application works well.

This is the code that works well on a website but  cant work on mobile phone.
$db_handle = mysql_connect("localhost","dbname","password");

If I substitute the localhost above, with the IP address or domain name is still not working. Any help will be appreciated.