0

This is my server request call, where I save user info into my remote database server.

+ (void)sendRequestToServerForCreatingUserModel:(UserModelClass *)userModelClass
{
    NSLog(@"userModelClass.user_country_code %@", userModelClass.user_country_code);
    NSString *noteDataString = [NSString stringWithFormat:@"user_account_creation_time=%@&user_name=%@&user_password=%@&user_phone_number=%@&user_email=%@&user_country_code=%@&user_country_name=%@&user_profile_image_url=%@&user_cover_image_url=%@&user_facebook_id=%@&user_twitter_id=%@&user_google_id=%@&user_instagram_id=%@&user_vk_id=%@&user_pinterest_id=%@&user_date_of_birth=%@&user_address=%@&user_latitude=%@&user_longitude=%@&user_deposit_amount=%@&user_have_order=%@&user_have_deliver=%@&user_have_any_discount_offer=%@&user_payment_option=%@&user_social_media_pages=%@", userModelClass.user_account_creation_time, userModelClass.user_name, userModelClass.user_password, userModelClass.user_phone_number, userModelClass.user_email, userModelClass.user_country_code, userModelClass.user_country_name, userModelClass.user_profile_image_url, userModelClass.user_cover_image_url, userModelClass.user_facebook_id, userModelClass.user_twitter_id, userModelClass.user_google_id, userModelClass.user_instagram_id, userModelClass.user_vk_id, userModelClass.user_pinterest_id, userModelClass.user_date_of_birth, userModelClass.user_address, userModelClass.user_latitude, userModelClass.user_longitude, userModelClass.user_deposit_amount, userModelClass.user_have_order, userModelClass.user_have_deliver, userModelClass.user_have_any_discount_offer, userModelClass.user_payment_option, userModelClass.user_social_media_pages];

    NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
    NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration:defaultConfigObject delegate: nil delegateQueue:[NSOperationQueue mainQueue]];
    NSString *fileName = @"sendRequestToServerForCreatingUserModel.php";
    NSURL * url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@", kServerBaseURL, fileName]];
    NSMutableURLRequest * urlRequest = [NSMutableURLRequest requestWithURL:url];
    [urlRequest setHTTPMethod:@"POST"];
    [urlRequest setHTTPBody:[noteDataString dataUsingEncoding:NSUTF8StringEncoding]];

    NSURLSessionDataTask * dataTask = [defaultSession dataTaskWithRequest:urlRequest completionHandler:^(NSData *dataRaw, NSURLResponse *header, NSError *error) {
        [[NSNotificationCenter defaultCenter] postNotificationName:@"sendRequestToServerForCreatingUserModel" object:error];
    }];

    [dataTask resume];
}

In this line :

NSLog(@"userModelClass.user_country_code %@", userModelClass.user_country_code); 

it shows that userModelClass.user_country_code variable has + in it. Like : +880. But in my remote server table row, it save as 880!

enter image description here

What I am missing here? Any suggestion would be highly appreciated.

Thanks in advance.

Tulon
  • 4,011
  • 6
  • 36
  • 56
  • The column is probably of an integer type. So the plus is just seen as if it is a positive number. – Ivar Oct 20 '17 at 17:27
  • At first I was thinking the same. But nope. Except primary key, all other attributes are in String. But thanks for mentioning the point. – Tulon Oct 20 '17 at 17:29
  • By the way, I put `+` manually, I mean by myself in table cell, and it show & read perfectly. So table configuration is fine here. – Tulon Oct 20 '17 at 17:33
  • Alright. My best guess would be that it is converted in your code somewhere to an integer then. Because it is a bit too coincidental that only the plus is missing. (You might try to add an leading 0 in front of it as well, those should vanish as well.) – Ivar Oct 20 '17 at 17:35
  • I am 100% sure, it is `NSSting` type all over my project, and there is no way to make it into `NSInteger`. But sadly It is not taking the goddamn `+` in it. – Tulon Oct 20 '17 at 17:40

1 Answers1

0

Normally this is an issue with converting an integer to a VARCHAR, as it would take the + sign to mean positive, and just remove it. However, I don't know enough about Object-C so I can't tell if you are directly concating the userModelClass.user_country_code variable with the rest of your query? generally you would do something like '$userModelClass.user_country_code' to add the variable into your query.