The Best Way to Connect Your iOS App to MySQL Database (4 Steps)

Hi Chris,

Thanks for posting this article. I have been looking for similar for a project that I am working on for my startup. However I have two questions to ask:

  1. In the article you post an example of some PHP code used to connect with the MySQL database. Below the code it says:
    In line 4, you’ll want to change the following placeholders:
    -username : use the username of the db user that you set up in step 1
    -password : use the password for the db user
    -dbname : use the name of the database you created in step 1
    Read the comments in the code above to see what each line does.

My problem is… there are NO comments that I can see or find in the website to better understand how to make this work. can you please post the code and include the comments and perhaps some expamle so that I can understand what I need to modify?

// Add each row into our results array
$tempArray = $row;
array_push($resultArray, $tempArray);

// Finally, encode the array to JSON and output the results
echo json_encode($resultArray);


// Close connections

  1. This code is use to pull data from the MySQL server database is there code that will allow me to post data to the SQL server database?