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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:40:58+00:00 2026-05-24T07:40:58+00:00

When we insert a string with ampersand character into mysql, the string is inserted

  • 0

When we insert a string with ampersand character into mysql, the string is inserted only till & character is encountered.

Example: when inserting “one & two”… only “one ” is inserted.

Tried a few things like… htmlentities OR htmlspecialchars… nothing working for me.

Current PHP code:

$sms = htmlentities($_POST["sms"]);


$query = "INSERT INTO sms (detail,catID,deviceID) VALUES ('".$sms."',".$_POST["catID"].",'".$_POST["deviceID"]."')";

And as the app is live… I need to resolve it by editing the PHP files only, on the server. (I hope it can be done)

  • 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-24T07:40:59+00:00Added an answer on May 24, 2026 at 7:40 am

    Ok, well to complete the discussion, couldn’t found a server side only solution… requires modification at both client & server side.

    Here’s how I needed to pass the upload text (as newStr):

        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30];
    [request setHTTPMethod:@"POST"];
    
    NSString *newStr = (NSString *)CFURLCreateStringByAddingPercentEscapes(
                                                                                   NULL,
                                                                                   (CFStringRef)uploadText.text,
                                                                                   NULL,
                                                                                   (CFStringRef)@"&",
                                                                                   kCFStringEncodingUTF8 );
    
    NSString *parameters = [[NSString alloc] initWithFormat:@"sms=%@&catID=%d&deviceID=%@",newStr,webCatID,[[UIDevice currentDevice] uniqueIdentifier]];
    
    [newStr release];
    

    And this modification on the server side:

        if ( get_magic_quotes_gpc() )
    {
        $_POST['sms'] = stripslashes($_POST['sms'] );
    }
    
    $query = sprintf("INSERT INTO sms (detail,catID,deviceID) VALUES ('%s', '%d', '%s')",
                     mysql_real_escape_string($_POST['sms']),
                     ((int) $_POST['catID']),
                     mysql_real_escape_string($_POST['deviceID']));
    

    Special thx to @PhpMyCoder & @Shef

    & LOL on the urgency!

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

Sidebar

Related Questions

How can one insert a Unicode string CSS into CleverCSS ? In particular, how
I'm trying to insert a comment character into a string something similar to this:
I am trying to insert a very long text string into a MySQL Blob
I have to insert a string after a certain character using Ruby. For example,
I need to insert string to text file, for example, before first line from
string.insert in c# doesn't overwrite the character that is in the startindex does it?
I am trying to insert a string in MySQL table. But the following is
I need to insert an HTML string into the <head> tag of the current
I have to insert a string into a sqlite data base my command ..
I need to insert a string 'GMT' into 2010-07-13T11:22:33-07:00 before the last '-' (it

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.