Connect app to mysql

Hello, I've been researching some opitons to connect my app to my mysql database and the articles I've seen are pushing for paid services to connect the php files. I'm not opposed to paying but they seem like sketchy links. Which service providers do ya'll use?

Replies

Hi, what you can do is to create own php file on your server which can deal with MySQL and give results as JSON

Then your app can get that JSON file from your server

it works fine.

Not need to pay for anything here.


Just write the php file on your server : myPhpFile.php


And request like this

let url = addressIPServer + "/myPhpFile.php"


let myUrl = URL(string: url)

let request = NSMutableURLRequest(url:myUrl!);

Thanks for the recomendations ya'll, After spending a better part of the day I figured out how to set up a server here on my computer. If this helps someone out in the future heres a good tutorial to do that https://medium.com/@JohnFoderaro/how-to-set-up-apache-in-macos-sierra-10-12-bca5a5dfffba

I agree with your advice in general but I have some feedback about your code snippets:

let url = addressIPServer + "/myPhpFile.php"

Building a URL via string concatenation (or substitution) can get you into problems with quoting. While that’s not an issue here, it’s best to get into the habit of using

URLComponents
.
let request = NSMutableURLRequest(url:myUrl!);

Modern code should use

URLRequest
, which is a Swift value type that subsumes both
NSURLRequest
and
NSMutableURLRequest
.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"