Problem With Special Charecters and NSUrlConnection

Discussion in 'iOS Programming' started by CNuland, Jul 29, 2010.

  1. CNuland macrumors newbie

    Jun 17, 2010
    I'm sending a string that has GPS information (including the special charecters like degree, quotation, etc) via a NSUrlConnection. However, the server is not grabbing the information. It does grab the other strings I send though and I also print the GPS string before it sends and it is correct. My theory right now is that the PHP and/or the MySql statement is confused by the special characters in the GPS string sent via the iphone. Here's the block of code that sends the gps string.

    			[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]]; 	
    			[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"gps\"; filename=\"%@\"\r\n",image.gps] dataUsingEncoding:NSUTF8StringEncoding]];  
    			[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]]; 
  2. tinaCEO macrumors newbie

    Jul 30, 2010
    Use debugging software to solve your code error.
  3. seepel macrumors 6502


    Dec 22, 2009
    I've had similar problem with NSURLRequest. Are you properly URL encoding your strings? NSString doesn't quite do the job (I believe it is a known bug). If you google OathConsumer you'll find a google code package that has some nice categories on NSString and NSURLRequest that are very helpful for stuff like this. Also, on the server side make sure that you are escaping your SQL statements, I believe the function is something like real_mysql_escape_string.

Share This Page