0
votes

I am making an iOS app for which I have made the RDS mysql on amazon any idea how to connect the amazon RDS in iOS.

<?php
// we connect to example.com and port 3307


define("HOST", "dbinstance.jjjjj.us-east-1.rds.amazonaws.com");



define("USER", "test"); // Replace the ??'s with your database user login name
define("PASSWORD", "test"); // Replace the ??'s with your database user's login password
define("DB", "test"); // Replace the ??'s with your database name



$connection = mysql_connect(HOST, USER, PASSWORD) or die(mysql_error());
$database = mysql_select_db(DB) or die(mysql_error());


?>
2
are you able to connect to local MySQL ? what you have tried?Hardik Bhalani
yes I am able to connect using razor sqluser3278422
hey can you please tell me what is razor sql and how to use it?ThanksMinakshi

2 Answers

1
votes

You don't. Mobile applications should never connect directly to your database server — doing so is a security risk, as it allows any user with the database credentials (that is, any user who downloads your application!) to connect to your database and read or modify any data without restriction.

An example of the havoc that can be caused by an architecture like this can be seen here, where a game developer had their game's online high scoring system and level editor destroyed when someone discovered that it was working this way:

http://forums.somethingawful.com/showthread.php?noseen=0&threadid=2803713&pagenumber=258#post398884189

Create a web service which implements the necessary operations for your database, including access controls, and have your iOS application connect to and interact with that.

0
votes

Looking at your comments ,Need to clarify that ..for now you can consider amazon rds is is same as your local database residing remotely,

  1. you have to learn how to make php webservices first (not with rds amazon - it is one of distributed relational database service by Amazon.com)
  2. than how to call that php webservice from iOs and
  3. than just changing the DB connection url to the url which points to the amazon rds