Zack
Zack

Reputation: 871

Getting Error Submitting Data to DB From iOS app using PHP

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];

Upvotes: 1

Views: 105

Answers (1)

FluffulousChimp
FluffulousChimp

Reputation: 9185

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.

Upvotes: 1

Related Questions