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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:03:24+00:00 2026-06-02T19:03:24+00:00

Alright I’ve been messing around with this for hours now and I still can’t

  • 0

Alright I’ve been messing around with this for hours now and I still can’t get it right so I’m gonna ask you guys.

I have a textarea in html, The value needs to be send to php using ajax(jquery) then imputed to the database, and printable again using php. The problem is i want when printing to be 100% the same as what you typed in. including characters like ' and \

How I do it now:

var comment = escape( box.find('#newCommentArea').val() ).replace(new RegExp( "\\+", "g" ),"%2B");

Where box.find('#newCommentArea').val() is the value. I pass comment to php using ajax function and submit it as POST data.

using firebug this is what is appears to send: comment=asdf%27asdf

printing $_POST['comment'] in php gives me asdf\'asdf

the added \ is a problem. and i need to get rid of it.

either way because only javascript escape isn’t safe in php i also do urlencode()

and when printing i use rawurldecode()

Could you guys point out if this method is good, or if it could be done better.

And how do i get rid of the new \ in $_POST['comment']

Thanks in advance,

MakuraYami

  • 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-06-02T19:03:26+00:00Added an answer on June 2, 2026 at 7:03 pm

    The slashes are automatically added, a setting of PHP or the server which can be changed (but usually shouldn’t). You can reverse it using stripslashes() (PHP: stripslashes). Use this function immediately before displaying, so not before storing in the database.

    You don’t need to urlencode in PHP anymore if it was already sent (the urlencode needs to be before sending), you just need to make sure it’s database safe.

    Unfortunately I can’t advise you on what’s the best way for URL encoding, I tend to get confused by it myself 🙂 Hopefully someone else will be able to clarify that.

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

Sidebar

Related Questions

Alright so I have been looking around (on SO and Google) to see if
Alright, I've been hacking around with GD Image for a couple of months, and
Alright. This may be difficult but I have been struggling for quite a bit
Alright I've been debugging the whole day but can't figure out what the problem
Alright, I understand that this problem has been asked a lot of times at
Alright, this one's got me seriously stumped, after trying things out for hours with
Alright guys, this should be a very simple request. I'd like to run a
Alright, I am so close to finishing this I can taste it. Over the
Alright, I'm trying to figure out why I can't understand how to do this
Alright I don't see why this isnt working. It seems pretty simple. Here is

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.