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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:10:32+00:00 2026-05-31T01:10:32+00:00

I am putting a serialized data to database. Data comes from input field and

  • 0

I am putting a serialized data to database. Data comes from input field and it can be anything (string), also with quotes signs. Serialized data I encode with base64 to preserve serialize to result error. But quotes marks became \’. I am aware that it is mysql injection remedy, and encoded data has crypted \’ signs. Magic_quotes are on.
Here’s the code:

$_POST[‘post’]:

[0] => this is \"test\"
[1] => test2
[2] => quotes \"\"

php:

$db  = base64_encode(serialize($_POST['post']));

Now i get serialized and encoded data.
When I try to retrieve it:

[mysql functions to retrieve row]
$arr = unserialize(base64_decode($arr));
    foreach ( $arr as $arr1 ) {
    $arr2[] = stripslashes($arr1);
}
print_r($arr2);

After data retrieval I get as intended:

$arr2:

[0] => this is "test"
[1] => test2
[2] => quotes ""

Question is: is it mysql injection safe? Is it safe at all to put data from arr2 into html page into input fields and body of page? If not what would be a good method to do it? Should I use html_escape and mysql_special like functions ?

Thanks in advance 🙂

EDIT:
string data from database will be used only as a value of input and textarea html tags.

  • 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-31T01:10:33+00:00Added an answer on May 31, 2026 at 1:10 am

    It’s happening because you’ve got magic quotes enabled. Magic quotes are deprecated.

    Since you’re using your own method to avoid injection issues, if you are unable to change the magic quotes setting for your installation, then stripslashes before you base64_encode the data – not when you decode it.

    (I assume you are aware that the data structure you are creating is opaque to the DBMS thereby breaking normalization rules and making it impossible to query the data effectively).

    string data from database will be used only as a value of input and textarea html tags.

    So you may (at a significant cost) have solved the sql injection problem but are not bothered about XSS attacks?

    Use the provided functions for changing the representation of data according to where you are sending the data (i.e. mysql_real_escape_string, htmlentities etc).

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

Sidebar

Related Questions

When putting a favicon on your site, you can apparently use an animated gif,
Whilst putting together a T4 template I threw in a simple lambda expression: <#=string.Join(,,
For putting together a site from scratch, what are the advantages and disadvantages of
Putting aside the disdain from junk marketing I need to send around 15,000 emails
I want to send secure data(strings) from a client to a server. This is
Data sent from client will not get deserialized. Client: $.ajax({ type: 'POST', dataType: json,
Putting this at the top of your CSS file: * { margin: 0; padding:
Putting code at aspx files is slower? The code is recompiled every access? At
Update Putting this at the top because it is crazy :) So some users
I putting wmd on my website. After putting code in and giving it a

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.