Anyone have any suggestions on how to set up both the php and the cocoa side of calling php functions? As a quick idea of what I want to do, I want to be able to to populate two tables with data and add/remove data from the db. So I want to set up a few functions in php that I can call from my iPhone code that will return values from my queries. I should note that my db is MySQL.
Mostly I'm interested in the syntax so if you have any code examples that I can play around with that would be super helpful.
Thanks in advance!
Well, to get some data over HTTP protocol in iPhone, you could use:
NSString *urlstr = [[NSString alloc] initWithFormat:@"http://www.yourserver.com/yourphp.php?param=%d", paramVal];
NSURL *url = [[NSURL alloc] initWithString:urlstr];
NSString *ans = [NSString stringWithContentsOfURL:url];
// here in ans you'll have what the PHP side returned. Do whatever you want
[urlstr release];
[url release];
Now, on the PHP, you can return the data the way you want. I.E., and XML which you will then parse on the iPhone side.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With