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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:21:14+00:00 2026-06-07T15:21:14+00:00

I have a working code which allows users to insert url’s into a database,

  • 0

I have a working code which allows users to insert url’s into a database, and display the contents of the database.

The problem im running into when i use ajax to addinto database is that if an url has the character “&” it cuts the url right before that character for example:

1. http://www.arisroyo.com/wp-content/uploads/2012/07/php.png
2. http://www.arisroyo.com/wp-content/uploads/2012/07/test&123.png

When adding url 1 to the database i have no problems, but when adding url 2 to the database i get this added to the database:

http://www.arisroyo.com/wp-content/uploads/2012/07/test

It ignores anything after the “&” sign. The problem is that all of my urls will be using the “&” sign.

This is the code im using on AJAX to get the url from the user from the website:

var nocache = 0;
function insert() {
// Optional: Show a waiting message in the layer with ID login_response
document.getElementById('insert_response').innerHTML = "Just a second..."
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
var site_url= encodeURI(document.getElementById('site_url').value);

// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http.open('get', 'insert.php?site_url='+site_url+'&nocache = '+nocache);
http.onreadystatechange = insertReply;
http.send(null);
}
function insertReply() {
if(http.readyState == 4){
var response = http.responseText;
// else if login is ok show a message: "Site added+ site URL".
document.getElementById('insert_response').innerHTML = 'Site added:'+response;
}
}

I’ve been using the addinto mySQL without ajax, and never had a problem with the url and the “&” sign. I’d like to know what might be causing this problem.

  • 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-07T15:21:15+00:00Added an answer on June 7, 2026 at 3:21 pm

    I solved it by simply adding the word component to econdeURI like so:

    var site_url= encodeURIComponent(document.getElementById(‘site_url’).value);

    I only post here when I’m completely stomped, so I’m sorry to have wasted your time! but thanks for taking the time to check out my question

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

Sidebar

Related Questions

I'm working on some code which fills a GridView full of images that have
I have code which as been working against an older Active Directory server and
I have the follwing code (which is not working): private void Window_PreviewKeyDown(object sender, KeyEventArgs
I have jquery validation code which is working fine in ff but the same
I have trouble to get gluLookAt working. I have the following code which works
Hi Javascript gurus, I have this Javascript code which is working fine on Firefox
I have the simple following code, which is working in a ruby (not rails)
I have a very simple code, which annoyingly was working and for the life
I have created an invite friends code, which is properly working if an FB
I'm currently working on my first Django app, which allows registered users to submit

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.