ios - jsonFile PHP server problems -


i trying server data dump table on iphone. flow standard server - php_interface - ios. trying echo json_encode(array) setup when doing wasnt able populate array, (with excellent stack users) switched setup , forwent json_encode(array) setup. realise need if ios connection. input @ end of current php code doesnt seem work. quite confident code on ios side working cuz build shows array isnt populating, , error message getting in xcode saying found 0 rows. please?

current code (that trying work):

    $mysqli = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);     $query = "select name, address, latitude, longitude locations";     $result = mysqli_query($mysqli, $query);      if($result) {         while ($row = mysqli_fetch_assoc($result)) {             echo 'name: ' . $row['name'] . '<br />';             echo 'address: ' . $row['address'] . '<br>';             echo 'latitude: ' . $row['latitude'] . '<br>';             echo 'longitude: ' . $row['longitude'] . '<br>';                 echo ''. '<br>';  json_encode($result);         }     } 

old code snippet never worked fully:

if (mysqli_connect_errno()) {   echo "failed connect mysql: " . mysqli_connect_error(); }  $sql = "select * `locations` ";  if ($result = mysqli_query($con, $sql)) {  $resultarray = array();  $temparray = array();   while($row = $result->fetch_object(locations)){    $temparray = $row;     array_push($resultarray, $temparray);  }   echo json_encode($resultarray); }  // close connections mysqli_close($con); ?> 

xcode metod getting rows:

- (void) downloaditems{     // download json file     nsurl *jsonfileurl = [nsurl urlwithstring:@"http://server.com/service.php"];      // create request     nsurlrequest *urlrequest = [[nsurlrequest alloc] initwithurl:jsonfileurl];      // create nsurlconnection     [nsurlconnection connectionwithrequest:urlrequest delegate:self];  } 

i messed ans parsed locations in php method. remove , "old" code works fine.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -