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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:07:34+00:00 2026-06-13T09:07:34+00:00

I am making this chat app with works with a .php file on my

  • 0

I am making this chat app with works with a .php file on my webserver to store the data in a SQL db

Here is my code so far:

#import "vtchatViewController.h"

@interface vtchatViewController ()

@end

@implementation vtchatViewController

@synthesize messageBox, messageView, Send, Refresh;


- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    NSString *usrName = [[NSUserDefaults standardUserDefaults] stringForKey:@"user_name"];

    NSURL *url = [NSURL URLWithString:@"http://server.com/ios/messages.php"];  [messageView loadRequest:[NSURLRequest requestWithURL:url]];

}

- (IBAction)refreshButton:(id)sender {
    NSURL *url = [NSURL URLWithString:@"http://server.com/ios/messages.php"];  [messageView loadRequest:[NSURLRequest requestWithURL:url]];

}

- (IBAction)sendButton:(id)sender {
    // server.com/ios/add.php?user=Username here&message=Message Her

    [messageBox resignFirstResponder];
    NSString* urlString = [[NSString stringWithFormat:@"http://server.com/ios/add.php?user=",usrName "&message=%@", messageBox.text] stringByAddingPercentEscapesUsingEncoding : NSUTF8StringEncoding];
    NSURL *add = [NSURL URLWithString:urlString];



    [messageView loadRequest:[NSURLRequest requestWithURL:add]];
    messageBox.Text = @"";


}



- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

However on the line “viewDidLoad” I can’t get it to use the username from my settings bundle:

NSString* urlString = [[NSString stringWithFormat:@"http://server.com/ios/add.php?user=",usrName "&message=%@", messageBox.text] stringByAddingPercentEscapesUsingEncoding : NSUTF8StringEncoding];
NSURL *add = [NSURL URLWithString:urlString];

I get the error “Use of undeclared indentifier ‘usrName’ and also I have no idea if I did implent the “usrName” correct for use in this

I simply need it to send data to “server.com/ios/add.php?” where data should be in this format: “user=Username here&message=Message here”

I got it working if I just use a fixed username, but as said, I have no idea how to make the thing use the username stored in my settings file

Thanks in advance

  • 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-13T09:07:35+00:00Added an answer on June 13, 2026 at 9:07 am

    You need to use string format tokens to get it to insert the username into the urlString variable like this:

    NSString* urlString = [[NSString stringWithFormat:@"http://server.com/ios/add.php?user=%@&message=%@", usrName, messageBox.text];
    

    That should help you understand why your format string wasn’t working and why you were getting that error. My code above isn’t escaping the values of usrName or messageBox.text so you’ll need to add those back into your code.

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

Sidebar

Related Questions

We're making this web app in PHP and when working in the reports we
I'm making this method retrieve records from the Data Base. As you can see
So im making this app where user could add UP to 3 images to
I'm making this calculation in my SQL statement: CD_WELLBORE_FORMATION.prognosed_md + {fn IFNULL(CD_DATUM.datum_elevation, 0)} How
I have used the signalR chat app (as laid out in this tutorial http://sergiotapia.com/2011/09/signalr-with-mvc3-chat-app-build-asynchronous-real-time-persistant-connection-websites/
I'm making a chat which is based on long polling (something like this )with
I am making a simple chat bot in Python. It has a text file
I'm making an iOS app like Kik messenger. I'm worried that the chat will
I'm making a chat room with a text file. Very simple, but I don't
This is similar to my last question. I'm making a simple tcp/ip chat program

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.