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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:27:49+00:00 2026-05-25T03:27:49+00:00

On my server I have magic_quotes turned off. When a user save content as

  • 0

On my server I have magic_quotes turned off.
When a user save content as article in my DB from a form, I use

$text = mysql_real_escape_string($_POST['text']); to prevent SQL Injecion.

This is my input <img src="image.png"></img> and this is what it is saved in the DB <img src="image.png"></img>

When I echo htmlentities($row['text']); i get <img src="image.png"></img> printed on screen, on view source I get &lt;img src=&quot;image.png&quot;&gt;&lt;/img&gt;.

My questions are

  1. Isn’t supposed to be saved in DB like <img src=\"image.png\"></img> to prevent SQL Injections ?
  2. Is htmlentities is a good candidate to prevent XSS attacks?
  3. Should I turn on magic_quotes?
  • 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-25T03:27:50+00:00Added an answer on May 25, 2026 at 3:27 am

    Isn’t supposed to be saved in DB like <img src=\"image.png\"></img> to prevent SQL Injections ?

    No, SQL injections are widely misunderstood, mainly because they actually have nothing to do with SQL as they are just string manipulation. You don’t need to alter the data you insert into the database, you only have to alter the string you send to the database server as query (unless you do the wise choice and use prepared statements instead of escaping the query string). The data, once stored, should be in its original state.

    Is htmlentities is a good candidate to prevent XSS attacks?

    Yes but htmlentities() is good for sending data as output to the browser, not for storing it into the database (as the data from the DB might be used for something other than a web page).

    Should I turn on magic_quotes?

    No, you should use prepared statements.

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

Sidebar

Related Questions

I have a client-server Silverlight application, which is use Socets. I have server appliaction
On a server I have to take care of, errors from a vhost do
I have a large file I want to download from a server I have
If I have this in my Site.Master file: <link href=../../Content/Site.css rel=stylesheet type=text/css /> and
I have a Debian Lenny server, from where I run my websites - Zend
I have a Client/Server application, where the Client and Server have some common tables
My server have default php version of 4, so when I run some script
Does each column of a table in SQL Server have a unique id? I've
In SQL Server I have a DATETIME column which includes a time element. Example:
A single Biztalk Server can have multiple Host processes. Is it possible to create

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.