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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:07:27+00:00 2026-05-15T08:07:27+00:00

I am working on a form with the possiblity for the user to use

  • 0

I am working on a form with the possiblity for the user to use illegal/special characters in the string that is to be submitted to the database. I want to escape/negate these characters in the string and have been using htmlspecialchars(). However, is there is a better/faster method?

  • 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-15T08:07:27+00:00Added an answer on May 15, 2026 at 8:07 am

    If you submit this data to the database, please take a look at the escape functions for your database.

    That is, for MySQL there is mysql_real_escape_string.

    These escape functions take care of any characters that might be malicious, and you will still get your data in the same way you put it in there.

    You can also use prepared statements to take care of the data:

    $dbPreparedStatement = $db->prepare('INSERT INTO table (htmlcontent) VALUES (?)');
    $dbPreparedStatement->execute(array($yourHtmlData));
    

    Or a little more self explaining:

    $dbPreparedStatement = $db->prepare('INSERT INTO table (htmlcontent) VALUES (:htmlcontent)');
    $dbPreparedStatement->execute(array(':htmlcontent' => $yourHtmlData));
    

    In case you want to save different types of data, use bindParam to define each type, that is, an integer can be defined by: $db->bindParam(':userId', $userId, PDO::PARAM_INT);. Example:

    $dbPreparedStatement = $db->prepare('INSERT INTO table (postId, htmlcontent) VALUES (:postid, :htmlcontent)');
    $dbPreparedStatement->bindParam(':postid', $userId, PDO::PARAM_INT);
    $dbPreparedStatement->bindParam(':htmlcontent', $yourHtmlData, PDO::PARAM_STR);
    $dbPreparedStatement->execute();
    

    Where $db is your PHP data object (PDO). If you’re not using one, you might learn more about it at PHP Data Objects.

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

Sidebar

Related Questions

VS2010 C# .Net 4.1 I am working on a form that the user must
Im trying to get a form working in Internet Explorer. I see that when
Im working on a form that needs a password that is between 6 and
I am working on web form which collects certain user information from users and
I'm working with a form that I've altered from another site I created, which
I am working on a form that adds employee information to a MySQL table
I am working with a VB window that seems to want to resize depending
My form is working fine with the validations being done by PHP. I have
I'm working on a form in .NET and am using the standard field validators.
I am working on some form coding in PHP, and I have everything working

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.