iPhone: Try to send html code to a php script (but fail)

Posted by Marc-André Weibezahn on Stack Overflow See other posts from Stack Overflow or by Marc-André Weibezahn
Published on 2011-01-12T16:51:08Z Indexed on 2011/01/12 16:54 UTC
Read the original article Hit count: 149

Filed under:
|
|

Hello all,

I am trying this for an iPhone app in Xcode:

  • create html code for a website on the fly
  • sending it to a php-script and getting the response with this code:
    NSError * error = [[[NSError alloc]init]autorelease];
    NSURL * phpURL = [NSURL URLWithString: @"http://www.mydomain.com/myscript.php?mywebsite= (...websitestring...) ];
    NSString * myResponse = [NSString stringWithContentsOfURL:phpURL encoding:NSUTF8StringEncoding error:&error];

It does not work. It should not be a problem of the php code because when I replace the websitestring which contains the html code with "hello" or something, this is accepted. (the script then creates a file "test.html" with the content I sent.) But when I put html code in it, I always get the error:

Error Domain=NSCocoaErrorDomain Code=256 "The operation couldn’t be completed. (Cocoa error 256.)" UserInfo=0x322ec10 {}

It seems that there are some things to consider when sending code to php?

Thanks in advance!

© Stack Overflow or respective owner

Related posts about php

Related posts about iphone