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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:57:35+00:00 2026-05-12T06:57:35+00:00

In an article http://dev.mysql.com/tech-resources/articles/4.1/prepared-statements.html , it says the followings: There are numerous advantages to

  • 0

In an article http://dev.mysql.com/tech-resources/articles/4.1/prepared-statements.html, it says the followings:

There are numerous advantages to using prepared statements in your applications, both for security and performance reasons.

Prepared statements can help increase security by separating SQL logic from the data being supplied. This separation of logic and data can help prevent a very common type of vulnerability called an SQL injection attack.

Normally when you are dealing with an ad hoc query, you need to be very careful when handling the data that you received from the user. This entails using functions that escape all of the necessary trouble characters, such as the single quote, double quote, and backslash characters.

This is unnecessary when dealing with prepared statements. The separation of the data allows MySQL to automatically take into account these characters and they do not need to be escaped using any special function.

Does this mean I don’t need htmlentities() or htmlspecialchars()?
But I assume I need to add strip_tags() to user input data?
Am I right?

  • 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-12T06:57:35+00:00Added an answer on May 12, 2026 at 6:57 am

    htmlentities and htmlspecialchars are used to generate the HTML output that is sent to the browser.

    Prepared statements are used to generate/send queries to the Database engine.

    Both allow escaping of data; but they don’t escape for the same usage.
    So, no, prepared statements (for SQL queries) don’t prevent you from properly using htmlspecialchars/htmlentities (for HTML generation)

    About strip_tags: it will remove tags from a string, where htmlspecialchars will transform them to HTML entities.
    Those two functions don’t do the same thing; you should choose which one to use depending on your needs / what you want to get.

    For instance, with this piece of code:

    $str = 'this is a <strong>test</strong>';
    var_dump(strip_tags($str));
    var_dump(htmlspecialchars($str));
    

    You’ll get this kind of output:

    string 'this is a test' (length=14)
    string 'this is a &lt;strong&gt;test&lt;/strong&gt;' (length=43)
    

    In the first case, no tag; in the second, properly escaped ones.

    And, with an HTML output:

    $str = 'this is a <strong>test</strong>';
    echo strip_tags($str);
    echo '<br />';
    echo htmlspecialchars($str);
    

    You’ll get:

    this is a test
    this is a <strong>test</strong>
    

    Which one of those do you want? That is the important question 😉

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

Sidebar

Related Questions

Is there an explanation of these statuses anywhere? http://dev.mysql.com/tech-resources/articles/using-new-query-profiler.html my specific question is in
I was going through this article http://dev.opera.com/articles/view/objects-in-javascript/ where I read 'this' keyword doesn’t always
I was going through this article : http://www.ajaxline.com/32-tips-to-speed-up-your-mysql-queries at point#4 , it states :
I am having trouble understanding the following article: http://www.ibm.com/developerworks/java/library/j-jtp01255.html Under, Generics are not covariant
I have read this article (Link: http://guides.beanstalkapp.com/version-control/branching-best-practices.html ) that gives some good best practice
The tutorial at http://www.oracle.com/technetwork/articles/javase/gfandmysql-part2-138537.html , which is about GlassFish and MySQL, Part 2: Building
This article http://www.gnustep.org/resources/ObjCFun.html states that Anywhere that time is critical, it's possible in Objective-C
In this article: http://www.ibm.com/developerworks/java/library/j-jtp1029/index.html Brian Goetz states: Just because class X is compiled against
I read this article : http://lwuit.blogspot.in/2008/06/lightweight-text-input-in-lwuit.html This article talks of autocomplete textfield embedded on
i m using this article http://blogs.msdn.com/delay/archive/2009/09/23/if-it-walks-like-a-duck-and-talks-like-a-duck-it-must-be-a-treegrid-a-simple-xaml-only-treegrid-ui-for-wpf.aspx to have hierarchical data... i am having treeview

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.