I'm trying to find how to read data from my database in my iphone app. The database is in my server, what I tried is similar to how I do that in Android (I'm not sure if is the best way):
NSString *hostStr = @"http://www.myip/notices.php";
NSData *dataURL = [NSData dataWithContentsOfURL: [ NSURL URLWithString: hostStr ]];
NSString *serverOutput = [[NSString alloc] initWithData:dataURL encoding: NSASCIIStringEncoding];
NSLog(@"Mysql response:is %@",serverOutput);
What I get is "Mysql response: is Array", what is true:
<?php
mysql_connect("localhost","user","pass");
mysql_select_db("database");
$q = mysql_query("SELECT id, title FROM jos_content WHERE catid=12 AND state=1 AND DATE(publish_up) <= NOW() ORDER BY DATE(publish_up) DESC");
while($e=mysql_fetch_assoc($q))
$output[]=array("id" => $e['id'], "title" => utf8_encode($e['title']));
echo $e;
print($output);
mysql_close();
?>
how should I do it?
Thank you in advance