Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

iPhone And PHP Intergration

Options
  • 18-09-2010 1:43pm
    #1
    Registered Users Posts: 8,004 ✭✭✭


    Hi Folks,

    I'm looking to use PHP to query and update an SQL database. It will be in the simple call to a script with a few variables e.g. update.php?user=abc&&pass=123 etc

    On that point, how would I sent POST versus GET messages?

    What I'm looking to do is for the PHP script to return a value e.g. 1 = Updated DB 0 = Error and for the iPhone to interpret this. So return a value, assign to an int and on that int display a message.

    Or for another function, query a DB for a name and for the PHP to return all the information from that name e.g. Age, Address and display in a table. Would for the PHP to generate a XML file be a better way to go?

    I can write the PHP at a stretch but the iPhone side has me puzzled. I'm sure its an library I haven't found.

    Can anyone help me on that?

    Many Thanks,

    ironclaw


Comments

  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Let me get this straight; an iPhone queries a PHP script, which then does a look up on a MySQL database and returns a value which is then displayed (or triggers an appropriate display) on the iPhone?

    If so, you are talking about two separate applications; one for the client (iPhone) and one for the server (PHP, MySQL). I will presume that you have some basic technical understanding of the latter.

    There are various means that you can use to develop for the iPhone, from native Objective-C applications, through to some third party platforms, such as Titanium, and even just a Web-base thin client (eliminating the need for any knowledge in iPhone development, beyond UI).

    Given your post, I would suspect that your programming skills are limited, so perhaps the last of these may be the way to go. I've found MobiOne is not a bad WYSIWYG for knocking up prototype UI's, as HTML, for the iPhone - and once you've done that you could use the resultant code to act as a display layer for your server-based application.

    If you feel that a native iPhone app is a better idea, you'll find plenty of threads here that will point you in the right direction.


  • Registered Users Posts: 8,004 ✭✭✭ironclaw


    Let me get this straight; an iPhone queries a PHP script, which then does a look up on a MySQL database and returns a value which is then displayed (or triggers an appropriate display) on the iPhone?

    If so, you are talking about two separate applications; one for the client (iPhone) and one for the server (PHP, MySQL). I will presume that you have some basic technical understanding of the latter.

    There are various means that you can use to develop for the iPhone, from native Objective-C applications, through to some third party platforms, such as Titanium, and even just a Web-base thin client (eliminating the need for any knowledge in iPhone development, beyond UI).

    Given your post, I would suspect that your programming skills are limited, so perhaps the last of these may be the way to go. I've found MobiOne is not a bad WYSIWYG for knocking up prototype UI's, as HTML, for the iPhone - and once you've done that you could use the resultant code to act as a display layer for your server-based application.

    If you feel that a native iPhone app is a better idea, you'll find plenty of threads here that will point you in the right direction.

    Hi, I've actually come from a web development background and I'm currently learning Obj-C. While I'm not a master of either I am learning.

    I can get the PHP side to work, the trick is getting the iPhone to get a response. So if an update was successful to a SQL DB, the phone would get a response and act on it. If the update failed, the phone would get a different error code.

    What response does the PHP have to generate? Or would I be working with HTTP headers?


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    ironclaw wrote: »
    What response does the PHP have to generate? Or would I be working with HTTP headers?
    Whatever response your client finds easiest to read. I don't code in Objective-C, but my guess is that an XML based response may be the best way to go, in that Objective-C likely has an XML parser library you can use.

    How to implement this, and whether there are any issues you should be aware of (that you need to have a DTD referenced or text/xml content-type headers) that are specific to iPhone development are something you need to read up on.

    I'm afraid it's a case of RTFM.


  • Registered Users Posts: 184 ✭✭Razzuh


    I'm having a go at something similar. I've read up on a few options and there isn't any easy one as far as I can make out. I'm leaning towards using JSON. You might find this blog article helpful:
    http://tempered.mobi/%20
    It gives a simple example for a PHP JSON web service with code for both sides (PHP and obj-c). Don't miss the link to the source at the bottom.


  • Registered Users Posts: 2,232 ✭✭✭techguy


    +1 on JSON!

    From a PHP point of view JSON is very easy to work with. Not sure about the Obj-C side of things though.


  • Advertisement
  • Registered Users Posts: 8,004 ✭✭✭ironclaw


    Cheers folks. Finally making sense.


Advertisement