Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8371211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:06:33+00:00 2026-06-09T14:06:33+00:00

The following code works almost perfectly. I am connecting to a mysql server on

  • 0

The following code works almost perfectly. I am connecting to a mysql server on my localhost from Xcode using php in the middle. This in the end will be a login system:

NSString *strURL = [NSString stringWithFormat:@"http://localhost:8888/Check.php?user=%@&pass=%@",txtName.text,passName.text];

// to execute php code
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:strURL]];
NSError *e;
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&e];

// to receive the returned value
NSString *strResult = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]autorelease];

NSLog(@"%@",strResult);

NSString *success = @"Success";

if ([strResult isEqualToString:success]) {
NSLog(@"I realize that the two strings are the same");
}

else {
NSLog(@"The two strings are not the same");
}

The strResult prints out in the debugger the following items that I am telling the php file to echo back to me for the different conditions, (if the username and password is right or wrong)

However, for some reason the if statement part of the code is always going to the else method even though in the output it specifically says that the string, strResult, is containing the word “Success”.

This is so irritating because I can see that both strings, (strResult and success), are equal to each other but for some reason Xcode cannot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T14:06:35+00:00Added an answer on June 9, 2026 at 2:06 pm

    Your strResult might contain whitespace at the end. Try logging like this to get a hex dump of the characters in the string:

    NSLog(@"strResult = %@", [strResult dataUsingEncoding:NSUTF8StringEncoding]);
    NSLog(@"success = %@", [success dataUsingEncoding:NSUTF8StringEncoding]);
    

    OR

    NSLog(@"%u",strResult.length);
    

    If it is a whitespace problem, you can trim it using the answer here: What's the best way to trim whitespace from a string in Cocoa Touch?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code, which almost works: <?php if( $_SERVER['REQUEST_METHOD'] == 'POST' )
In C#, the following code (from this page) can be used to lazily instantiate
The following code works almost perfect, thanks to the help received here : import
I'm using a try-catch block in the following Actionscript 3 code: try { this._subtitle
I'm using the following code to grab images from the web. It uses Gridview
The following code works fine on Linux but throws an exception on OS X
The following code works in all browser but IE8 and below. // Create Paragraph
The following code works fine in firefox but as with many other things, I
The following code works fine: person = {:a=>:A, :b=>:B, :c=>:C} berson = {:a=>:A1, :b=>:B1,
The following code works as expected on CentOS and Ubuntu O/s but not on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.