Where to start learning networking with Corona

Hi guys,
I’d like to start working with online (existing) databases to implement in my Corona projects. The thing is that I don’t know where to start. I’m pretty sure I can figure out the code, but are there some sites to pull data of for free (if that makes any sense)?
Kind regards

You can host a MySQL database for free at https://www.000webhost.com/. I have never used them personally, but they seem fairly well-trusted.

There are sample databases that you can import if you don’t want to create your own data. For testing purposes, though, I’d think you could just create a simple database with a couple tables and a few records.

Hi BuoyantForce,
Thanks for the fast reply! Would I be able to also make the app having to sign in to gain access to the database via https://www.000webhost.com/ ? I’m sorry, I’ve never really got in to databases and web dev.

No need to apologize. I’m a newbie myself.

You would would not want to connect to the database directly from your app. In fact, I’m not sure this is possible in Corona SDK. It would not be a good idea from a security standpoint even if it is possible.

Instead, you would want to use a server-side middleware, such as PHP, to retrieve the data from the server. Here is an old guide that explains how to do it in Corona SDK:

https://coronalabs.com/blog/2012/11/20/how-to-download-json-data-from-mysql-using-corona-sdk/

Here are the related docs:

https://docs.coronalabs.com/api/library/network/request.html

If you need to learn PHP and/or SQL, I recommend w3schools. Codecademy  provides great introductory tutorials if you feel the need to prepare for the more detailed guides.

Hi thanks! Atleast now I know where to start, which is the most difficult part most of the time :slight_smile:
Have a nice day!

You do not want your database expose to the Internet. When you start hosting things online, protecting a users login credentials and their data is paramount. So thinking “Security” from day one is important.

Normally the flow is:

Corona App: network.request(URLtoYourWebScript) ----> [Internet] —> [Your web server] —> some PHP or .NET script ----> your DB —> yourScript ----> [Internet] —> Your App’s network.request()'s Listener function —> do something with the result.

If you’re setting up a typical login system, you will probably need a script to register new users (register.php?) and a script to log them in (login.php?) though you may want to obscure the names a bit so they are not so obvious targets to hack. Remember these scripts can be called by any web browser or command line tool like curl or wget.

This tutorial covers the Corona side of connect to RESTful based API’s:

https://coronalabs.com/blog/2015/06/02/tutorial-connecting-to-restful-api-services/

There are plenty of other tutorials on how to hook up PHP to MySQL (and probably for .NET to MSSQL) out there to be found with a Google search.

Rob

You can also try Coronium LS which allows you to host from a local host.

You can host a MySQL database for free at https://www.000webhost.com/. I have never used them personally, but they seem fairly well-trusted.

There are sample databases that you can import if you don’t want to create your own data. For testing purposes, though, I’d think you could just create a simple database with a couple tables and a few records.

Hi BuoyantForce,
Thanks for the fast reply! Would I be able to also make the app having to sign in to gain access to the database via https://www.000webhost.com/ ? I’m sorry, I’ve never really got in to databases and web dev.

No need to apologize. I’m a newbie myself.

You would would not want to connect to the database directly from your app. In fact, I’m not sure this is possible in Corona SDK. It would not be a good idea from a security standpoint even if it is possible.

Instead, you would want to use a server-side middleware, such as PHP, to retrieve the data from the server. Here is an old guide that explains how to do it in Corona SDK:

https://coronalabs.com/blog/2012/11/20/how-to-download-json-data-from-mysql-using-corona-sdk/

Here are the related docs:

https://docs.coronalabs.com/api/library/network/request.html

If you need to learn PHP and/or SQL, I recommend w3schools. Codecademy  provides great introductory tutorials if you feel the need to prepare for the more detailed guides.

Hi thanks! Atleast now I know where to start, which is the most difficult part most of the time :slight_smile:
Have a nice day!

You do not want your database expose to the Internet. When you start hosting things online, protecting a users login credentials and their data is paramount. So thinking “Security” from day one is important.

Normally the flow is:

Corona App: network.request(URLtoYourWebScript) ----> [Internet] —> [Your web server] —> some PHP or .NET script ----> your DB —> yourScript ----> [Internet] —> Your App’s network.request()'s Listener function —> do something with the result.

If you’re setting up a typical login system, you will probably need a script to register new users (register.php?) and a script to log them in (login.php?) though you may want to obscure the names a bit so they are not so obvious targets to hack. Remember these scripts can be called by any web browser or command line tool like curl or wget.

This tutorial covers the Corona side of connect to RESTful based API’s:

https://coronalabs.com/blog/2015/06/02/tutorial-connecting-to-restful-api-services/

There are plenty of other tutorials on how to hook up PHP to MySQL (and probably for .NET to MSSQL) out there to be found with a Google search.

Rob

You can also try Coronium LS which allows you to host from a local host.