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

  • Home
  • SEARCH
  • 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 1014587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:16:24+00:00 2026-05-16T10:16:24+00:00

I have an iPhone app which submits user entered data to a SQL database.

  • 0

I have an iPhone app which submits user entered data to a SQL database. It causes an error, either cuts off the data or enters “null” when special characters are used. Seems that apostrophes and question marks and periods are ok, but anything outside of that causes it to cut off the post or post nothing at all.

My SQL Query to insert the data is as follows:

mysql_query("INSERT INTO tblQA (intResponseID, intPosterID, dPostDateTime, cCategory, cSubject, cBody) VALUES ($id, $u, NOW(), '$cat', '$sub', '$body');");

The field type in the database is a varchar(8000). SO, plenty of room where I know it’s not getting cut off because of limitation of characters. The Collation i’m using is “latin1_swedish_ci”

EDIT: I test again. It’s the “&” that is cutting off the string when posted to the SQL database. If I manuall insert from phpMyAdmin, I can insert string “Testing & Seeing if this works” with no problem.

iPhone code:

[p setObject:[NSString stringWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://website.com/script.php?user=%@&pass=%@&cat=%@&sub=%@&body=%@",[[p valueForKey:@"user"] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],[[p valueForKey:@"pass"] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],sport,@"",[[tvQ.text stringByReplacingOccurrencesOfString:@"\n" withString:@" "] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]]] forKey:@"q"];

Additionally:

If I manually insert a string with the ampersand (&) it will appear in the iPhone app. It’s only on the posting function, that it’s not working.

Added 3:20p 8/10/10:
I’ve done some additional testing and the INSERT query is working fine. I’ve created a separate script to take inputted data from a HTML page and inserted it just fine with the “&” symbol in it. Seems I need to take a look at what the iPhone is grabbing as a string and passing to the PHP script.

  • 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-16T10:16:24+00:00Added an answer on May 16, 2026 at 10:16 am

    Escape your data using mysql_real_escape_string. As an ugly but quick fix, that would look like

    $cat = mysql_real_escape_string($cat);
    $sub = mysql_real_escape_string($sub);
    $body = mysql_real_escape_string($body);
    mysql_query("INSERT INTO tblQA (intResponseID, intPosterID, dPostDateTime, cCategory, cSubject, cBody) VALUES ($id, $u, NOW(), '$cat', '$sub', '$body');");
    

    How special are your special characters? If they’re Unicode, you might need to SET NAMES UTF8 as described in How can I store Unicode in MySQL?.

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

Sidebar

Ask A Question

Stats

  • Questions 507k
  • Answers 507k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer VSCommands 2010 allows you to specify zoom level for newly… May 16, 2026 at 4:05 pm
  • Editorial Team
    Editorial Team added an answer (I'm imagining that you are parsing an Xml file) We'll… May 16, 2026 at 4:05 pm
  • Editorial Team
    Editorial Team added an answer Removal of "\" fixed the issue. Here is my command… May 16, 2026 at 4:05 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have an iPhone app which communicates with a server to get the data
So I have an iPhone app which should aid the user to find a
In our iPhone app we have a controller 'AddViewController' which shows a data entry
I have built an iPhone app that needs to pull data from a server.
I have an iPhone app which uses ASIHTTPRequest to communicate to a REST service
I have an iPhone app which has a tabBarController as the root view controller
I have an iPhone app which I need to test in an older version
I have an iPhone app which hides the status bar when run. After launching
I have built an iPhone app with 3.1.2 SDK. Can it be able to
I have current a developed app which I am going to submit in just

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.