in Education by
I'm making a 'post text' app and trying to update my database with name and body field. The obj-c code looks like this: - (IBAction)post:(id)sender { NSLog(@"%@", name); NSLog(@"%@", body); // create string contains url address for php file, the file name is post.php, it receives parameter :name NSString *strURL = [NSString stringWithFormat:@"http://www.mywebsite.com/post.php?name=%@&body=%@",name, body]; // to execute php code NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]]; // to receive the returend value NSString *strResult = [[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding]; NSLog(@"%@", strResult); } And the php code looks like this: <?php if (isset($_REQUEST['name']) && isset($_REQUEST['body']) && strlen($_REQUEST['name']) > 0 && strlen($_REQUEST['body']) > 0) { //get data $title = $_REQUEST['name']; $body = $_REQUEST['body']; mysql_connect("MyServer","username","password") or die(mysql_error()); mysql_select_db("Database_Name") or die(mysql_error()); $date = date("Y-m-d"); //insert data $insert = mysql_query("INSERT INTO news VALUES ('','".mysql_real_escape_string($title)."','".mysql_real_escape_string($body)."','".mysql_real_escape_string($date)."')") or die(mysql_error()); die("Your text has been posted!"); } ?> Sometimes it works to post through the app but then it just post (null) as name and null as body. But for the most part it doesn't work at all. It just says in the log: 2012-06-26 16:54:49.893 AppName[12444:707] > JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Taking a wild guess here but are name and body pointers to a UITextField object? I'm thinking they might be, based on your log output. If so, you need to use [name text] or name.text to get the actual NSString value from the text field.

Related questions

0 votes
    I'm still trying to understand this piece of code that I found in a project I'm working on where ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 20, 2022 in Education by JackTerrance
0 votes
    I'm still trying to understand this piece of code that I found in a project I'm working on where ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    If I have a table with results like this: 0001400OL 0578400OL 354085OL 48679OL and if I wanted to replace ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I've come to this code, but from this i have to manually insert all columns and check it by each ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    My objective-c app needs to be aware if the firewall in OSX is running, so it can tell the user ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    Using iOS 5's new TWRequest API, I've ran into a brick wall related with block usage. What I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    I want to get variable value from an objective-c class, using reflection. company.h looks like @interface ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 28, 2022 in Education by JackTerrance
0 votes
    I wanted to create a gallery. It loads different images based on the category, that a user selects. I used to populate ... ; int imgCount = [galleryImages count]; for(int i=0;i...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    Can we use both swift (.swft) and objective c (.h .m) in same xcode project ?...
asked Mar 9, 2021 in Technology by JackTerrance
0 votes
    How do I call Objective-C code from Swift?...
asked Mar 9, 2021 in Technology by JackTerrance
0 votes
    Explain the difference between Swift vs Objective-C.?...
asked Nov 30, 2020 in Technology by JackTerrance
0 votes
    What are benefits of collections views in Objective-C?...
asked Nov 10, 2020 in Technology by JackTerrance
0 votes
    How we can layout subviews in a view in Objective-C?...
asked Nov 10, 2020 in Technology by JackTerrance
0 votes
    What are the size classes in Objective-c?...
asked Nov 10, 2020 in Technology by JackTerrance
0 votes
    Why create a custom view in Objective-C?...
asked Nov 10, 2020 in Technology by JackTerrance
...