Re: URL string includes space

12 views
Skip to first unread message

Leonardo Parro Jr

unread,
Aug 24, 2012, 1:06:20 PM8/24/12
to iphonesdkd...@googlegroups.com
You need to encode the url string.

On Saturday, August 25, 2012 at 12:51 AM, don wrote:

From following code, question.php is called normally in case strMessage includes no space(for example "Test0001".
But, fails to call question.php in case strMessage includes space(for example "Test  0001".
How do I solve this?
---------------------------------------------------------------------------------------------
                         strUserID,
                         strMessage,
                         time(0) ];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
        [request setURL:[NSURL URLWithString:url]];//Sets the URL of the receiver
        [request setHTTPMethod:@"GET"];            //Sets the receiver’s HTTP request method
        //Returns an initialized URL connection and begins to load the data for the URL request.
        NSURLConnection *conn=[[NSURLConnection alloc] initWithRequest:request delegate:self];  
---------------------------------------------------------------------------------------------

--
You received this message because you are subscribed to the Google Groups "iPhone SDK Development" group.
To view this discussion on the web visit https://groups.google.com/d/msg/iphonesdkdevelopment/-/ONn3eJDgqmIJ.
To post to this group, send email to iphonesdkd...@googlegroups.com.
To unsubscribe from this group, send email to iphonesdkdevelop...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/iphonesdkdevelopment?hl=en.

Meghan Kharva

unread,
Aug 24, 2012, 1:04:10 PM8/24/12
to iphonesdkd...@googlegroups.com
try adding this:

                         strUserID,
                         strMessage,
                         time(0) ];

url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
....
--
-- Meghan Kharva


Reply all
Reply to author
Forward
0 new messages