Connecting iOS App to MySQL Database

I just read through and followed Chris’ --> The Best Way to Connect Your iOS App to MySQL Database (4 Steps) and ran into some problems and was hoping to find answers here.

Every time I run Chris’ code I run into the problem of poiCoodinates being nil and have no idea how to fix it. If anyone has run into this problem and found a way to fix it I would love any help thanks!

Can you post the service.php you are using? I am struggling on that part and it would help alot! I haven’t gotten to the part you are at!

Hello,

Though the question is posted two years ago but I’m having the same issue as op, I simply copied and pasted the php codes in the article:

<?php
 
// Create connection
$con=mysqli_connect("localhost","username","password","dbname");
 
// Check connection
if (mysqli_connect_errno())
{
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
 
// This SQL statement selects ALL from the table 'Locations'
$sql = "SELECT * FROM Locations";
 
// Check if there are results
if ($result = mysqli_query($con, $sql))
{
	// If so, then create a results array and a temporary one
	// to hold the data
	$resultArray = array();
	$tempArray = array();
 
	// Loop through each row in the result set
	while($row = $result->fetch_object())
	{
		// 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
mysqli_close($con);
?>

and then uploaded the file to my domain with replaced db name and pw, but accessing the php service using the /service.php url always return code 500, whereas some other photos uploaded to the public_html folder works just fine.

Hope someone could answer this question!