Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
how do I setup the following using asihttprequest:
user inputs first name in iphone app php file gets the first name data from the app php file queries the db and outputs the 'last name' corresponding to that first name, into the app
Can't seem to find a mysql/php example using an iPhone input and asihttprequest
break it down: 1- make the php script that take the input (using get or post as you prefer), do the query and give an output in xml or json. 2- see ASIHTTPRequest documentation to understand how to do a http request 3- see how to parse xml (NSXMLParser) or JSON (SBJson)
break it down: 1- make the php script that take the input (using get or post as you prefer), do the query and give an output in xml or json. 2- see ASIHTTPRequest documentation to understand how to do a http request 3- see how to parse xml (NSXMLParser) or JSON (SBJson)
Thanks Dany_dev! With the ASIHTTPRequest, I've found the webservices doc on here, including other examples, however, I cannot seem to find an example which utilises an input box with a submit button, then outputs in the iphone view?
ASIHTTPRequest contains a "responseString" property which allows you to see what the browser outputted back. For something like this, which I do not think is private data, you should be able to use simple GET over POST.
From there, you send a variable named "first_name" and your server will receive it as $_GET['first_name']; Here could be an example of your PHP script.
Thanks guys - maybe I should start again and explain why I'm having so much difficulty.
I followed the instructions with setting up a new project and importing all the classes.
I have now created a new view controller (.m and .h files)
From there, once I run the application, I want the user to be shown a textbox and submit button. Once they enter text and hit submit, the response is displayed below.
I have no problem setting up the PHP/MySQL end of things, it's the ASIHTTPRequest bit.
Replies
1- make the php script that take the input (using get or post as you prefer), do the query and give an output in xml or json.
2- see ASIHTTPRequest documentation to understand how to do a http request
3- see how to parse xml (NSXMLParser) or JSON (SBJson)
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeWith the ASIHTTPRequest, I've found the webservices doc on here, including other examples, however, I cannot seem to find an example which utilises an input box with a submit button, then outputs in the iphone view?
Thank you again.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesomeread entirely WebService [How-To]
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeFrom there, you send a variable named "first_name" and your server will receive it as $_GET['first_name']; Here could be an example of your PHP script.
include('database.php'); // Standard DB file
$first_name = mysql_real_escape_string($_GET['first_name']);
$query = mysql_query(\"SELECT * FROM `names` WHERE `first_name` = '$first_name';\");
if (mysql_num_rows($query) == 0) {
die('No results found for name: ' . $first_name);
}
$result = mysql_fetch_array($query);
echo $result['last_name'];
Now, the script will echo the last_name value, and you will receive this iPhone side through the responseString property.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI followed the instructions with setting up a new project and importing all the classes.
I have now created a new view controller (.m and .h files)
From there, once I run the application, I want the user to be shown a textbox and submit button. Once they enter text and hit submit, the response is displayed below.
I have no problem setting up the PHP/MySQL end of things, it's the ASIHTTPRequest bit.
Once my project is setup and blank, where to from there?
If I copy an example from the site (ASIHTTPRequest example code - All-Seeing Interactive) it brings up a bunch of errors.
Do I also need to use design view to add in the textbox and button or will the ASIHTTPRequest examples display them, using code?
Thanks for your help and your patience with me!
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome