1

I am trying to make it to where I can upload data into a MySQL DB when the user selects save. Everything works fine and uploads perfectly. The only time it doesn't work is if I select one part of the application. At first I thought it was because there was so much information uploading at once that the DB couldn't handle it. Then I realized after doing more research that this is not the case. After further investigating, I am able to NSLog the error and I get this error whenever I try to save:

Error Domain=NSURLErrorDomain Code=-1000 "bad URL" UserInfo=0x8191c20 {NSUnderlyingError=0x8490000 "bad URL", NSLocalizedDescription=bad URL}

If anyone could please help me and try to provide an explanation of what this error means, that would be so helpful. If the explanation alone does not help me I will then post the code but first I would like an explanation and see if I can figure out the problem on my own. Thanks!

EDIT

This is what I have in my URL for iOS side. Seems correct to me but I could be missing something:

    NSString *strURL = [NSString stringWithFormat:@"http://localhost:8888/signUp.php?prod=%@&comp=%@&phone=%@&cat=%@&autos=%@&notes=%@",prod.text,company.text,phone.text,cat.text,date.text,notes.text];
6
  • 1
    The URL is incorrect or improperly formatted. Often seen with characters that aren't escaped properly in the URL. Commented Dec 4, 2012 at 2:13
  • @NSBum SO I should look into the URL that I am submitting when making the request or would it be contained in the php file? Commented Dec 4, 2012 at 2:14
  • @NSBurn Check edit. If you find it let me know and if you want me to post more let me know Commented Dec 4, 2012 at 2:18
  • Yes, but what about escaping the contents of the actual URL params? Perhaps they contain invalid chars.... Look into stringByAddingPercentEscapesUsingEncoding: However, if you wanted to post an actual URL that gives the error we could say for sure. Commented Dec 4, 2012 at 2:22
  • I've looked at it and have figured out. But now I have another question. The reason it is not working is because the value that I am telling it to send has a number contained in it. (i.e. 5 Years). How do I fix it to make it be able to accept this string value? Commented Dec 4, 2012 at 2:25

1 Answer 1

1

Try:

NSString *strURL = [NSString stringWithFormat:@"http://localhost:8888/signUp.php?prod=%@&comp=%@&phone=%@&cat=%@&autos=%@&notes=%@",prod.text,company.text,phone.text,cat.text,date.text,notes.text];
NSString *escapedURLStr = [strURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:escapedURLStr];

Caveat - not tested.

Sign up to request clarification or add additional context in comments.

1 Comment

Stupid space lol. Works like a charm. Thanks a million for all of the help! +1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.