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 7662721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:52:24+00:00 2026-05-31T13:52:24+00:00

I have a PHP script on a server, all working fine for most of

  • 0

I have a PHP script on a server, all working fine for most of the thing I need it to do. I’m now setting up special user privileges for certain users.

I check if the logged in user is registered on a special user database, then return the name of their privleges or ‘blank’ using the following:

private function checkSpecialUser($userID)
{
    $db = new DbConnect();
    $result = $db->query("SELECT privelege FROM special_users WHERE userID = $userID");
    if ($privName = $result->fetch_object())
    {
        echo $privName->privelege;
    }
    else
    {
        echo 'blank';
    }
    $db->close();
}

In Xcode, I have set up a simple function to return the string which is returned by the PHP script (I’ll leave out the connection part since that all works fine):

NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&requestError];

NSString *packName = (NSString *)[[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
packName = [packName stringByReplacingOccurrencesOfString:@" " withString:@""];

NSLog(@"packName is %@", packName);

if([packName isEqualToString:@"blank"])
{
    NSLog(@"user is not special");
}
else
{
    NSLog(@"User is special :-)");
}
return packName;

Now to the problem I have. If the user does not have special privileges then the first NSLog prints “packName is blank” which is exactly what I would expect. However, the if statement should then pick up that packName is equalToString “blank”, which it doesn’t. It always reaches ‘else’ and prints “User is special :-)”.

I’ve double checked with users who ARE registered, and although it returns the string I would expect, again it doesn’t trigger an equalToString response.

Do PHP echoes have hidden characters in them that I would need to remove, or am I somehow getting the value from the database incorrectly? In the database each row is simply a userID which is a varchar, and the name of their privilege which is also a varchar.

If anyone has any tips I’d be really grateful. Thanks.

  • 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-05-31T13:52:26+00:00Added an answer on May 31, 2026 at 1:52 pm

    Try, instead of sending back “blank”, sending back nothing, or an empty string. Then, instead of matching the word “blank”, test the length of the string. This will at least tell you if there are other characters in packName… you might remove more than just space whitespace, if I had to guess I’d say you’ve got a newline in there.

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

Sidebar

Related Questions

I have a script on my server for uploading file. It is working fine
I have a PHP script on a server <?php // retrieve POST vars $comment
I have a php mail script sitting on a LAMP vps server. The script
My server have default php version of 4, so when I run some script
I have PEAR Mail and Mail_mime all working very nicely using gmail's SMTP server
I have a php script that allows users to upload multiple files to server
I have written/found a php script and I don't understand why it's working one
I need help with my php script. I am working on a script that
I have a simple PHP script that will either serve up a streaming ASF
I have php script that creates a temporary watermark image for users that are

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.