I'm getting database data through that php file:
<?php
$host = "localhost"; //Your database host server
$db = "company"; //Your database name
$user = "root"; //Your database user
$pass = "root"; //Your password
$connection = mysqli_connect($host, $user, $pass);
//Check to see if we can connect to the server
if(!$connection)
{
die("Database server connection failed.");
die(mysqli_error($db));
}
else
{
//Attempt to select the database
$dbconnect = mysqli_select_db($connection, $db);
//Check to see if we could select the database
if(!$dbconnect)
{
die("Unable to connect to the specified database!");
}
else
{
$tag=$_GET["tag"];
$resultset = mysqli_query($connection,"SELECT job,name FROM Employees where name LIKE '% $tag %'");
$records = array();
//Loop through all our records and add them to our array
while($r = mysqli_fetch_assoc($resultset))
{
$records[] = $r;
}
//Output the data as JSON
echo json_encode($records);
}
}
?>
All is working fine in the browser, I'm getting all data, however, I don't get anything in the iOS simulator, without any php error log.
-(void)getnameByTag:(NSString*)tag{
NSString *url = [@"http://localhost/get_name_by_tag.php?tag=" stringByAppendingString:tag];
NSLog(@"%@",url);
NSURL *urll= [ NSURL URLWithString:url];
NSURLRequest *request = [NSURLRequest requestWithURL:urll];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
arrayofJobs=[JSON valueForKeyPath:@"job"];
arrayofNames=[JSON valueForKeyPath:@"name"];
NSLog(@"authors: %@",arrayofJobs);
[[self employeesTableView] reloadData];
} failure:nil];
[operation start];
}
What could be the problem? iOS or php related problem ?
Thank you for your help.