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

  • Home
  • SEARCH
  • 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 9037639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:17:36+00:00 2026-06-16T09:17:36+00:00

I use ajax with php to output hyperlinks enabling user to email some text.

  • 0

I use ajax with php to output hyperlinks enabling user to email some text. The link points to a mail script and the querystring contains the text to mail. By clicking on the link, the user mails the text. However, if text (also user created) contains a quote mark, this quote mark appears in the querystring and breaks the code. Specifically, the browser thinks the querystring ends when it encounters the quote. The text after the quote spills out onto the page. I could enclose the hyperlink in an apostrophe instead of a quote, but then I’d have the same problem if the user included an apostrophe in the text.

I have tried to escape these special characters using json_encode but that did not work. I know there is addslashes or maybe I could hack somethin with str_replace, but would like to do this the right way.

Thanks for any suggestions on the right way to do this.

php

go to dbase

$text = $row['text'];

echo '<a href="sendmail.php?text='.$text.'">email text</a>';

/*
say for sake of argument text is 'the dimensions of the painting are 24" x 36"'

then above link is

echo '<a href="sendmail.php?text=the dimensions of the painting are 24" x 36"">email text</a>';
 which breaks code
*/
  • 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-16T09:17:37+00:00Added an answer on June 16, 2026 at 9:17 am

    urlencode should be used, since you’re encoding the text to put it in a URL.

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

Sidebar

Related Questions

I use php with ajax. <?php /* * Suppose, user has entered both correct
Use jquery + php. Doing custom AJAX captcha. i.e user clicks on image, it
I'm trying to use Ajax to call a PHP script to write to two
I am converting a javascript/php/ajax application to use jQuery to ensure compatibility with browsers
I'm developing some ajax script and using wordpress and my question is: is there
I've been trying to learn how to use jQuery AJAX with PHP. My problem
I am wanting to use the AJAX function via jQuery to return some data
I use below php code to send results of MYSQL databse search to AJAX
i would like to use ajax to retrieve information from a php page that
I have a php script, only for learning purposes. I would like to use

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.