How to connect to remote MYSQL database via php -
i have build android app connects remote mysql webserver , retrieve information display purpose. did research coz had no idea start. read article mentions better approach use php script. , didn’t know how server, database , php works, studied php here “http://www.homeandlearn.co.uk/php/php12p1.html” understand , downloaded whampserver testing. on local machine worked fine. main thing don’t understand “how connect remote server/database”. it’s obvious i’m doing stupid, need find out doing wrong. when test php script on local machine in webrowse use "localhost/some.php." when want test same php script on remoter server local machine , how should do? need make changes in configuration file on server side? have done more research before asking question here understand remote server connection in php still don’t understand. have gone through pages within link below: https://www.google.co.uk/search?q=connect+to+remote+mysql+webserver+php&rlz=1c1avsx_engb447gb448&oq=connect+to+remote+mysql+webserver+php&aqs=chrome.0.69i57j69i62l3.19724j0&sourceid=chrome&ie=utf-8#fp=5a2359cf96dc5f79&q=how+to+connect+to+remote+mysql+web+server+php
and appreciated. if question not clear please let me know i'll try explain more. or think of if have connect remote mysql server how , means process , steps involved in that. everyone.
edit
i have created database "dealt3_raj_test" on remote server. , when type "examplewebserver.co.uk/myphpscriptname" in web browser. gives me error "an error occurred , have reached error page"
<?php $user_name = "dealt3_raj"; $password = "5dn5nh&emd(vcr$dzk"; $database = "dealt3_raj_test"; $server = "examplewebserver.co.uk"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if($db_handle) { print "connected"; } else { print "can not connect server"; } if ($db_found) { print "database found"; } else { print "database not found"; } ?>
adding onto @user4035's comment, after opening connection, use jdbc in android/java code interact database.
that said, not practice. rather create web service
- your application may experience latency/connectivity issues. impact performance.
- your mysql server have open remote connections strongly advised against
- if android app intended public usage, means database username , password of mysql server reside on everyone's phone using app. encrypted or not makes database server "step less" secure
well answered here on so (jdbc vs web service android)
Comments
Post a Comment