Solved

unescaped & or unknown entity "&..."

Posted on 2006-11-28
3
578 Views
Last Modified: 2006-12-20
Hi,

If I'm using a php / mysql / databse program & have URLs that contain lots of ampersands, is there any way to get this to be considered not an error.  Is it an error?  Using Firefox's code checker I see

unescaped & or unknown entity "&..."

Thanks!!

Ubee...
0
Comment
Question by:a466-ub52
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 30

Expert Comment

by:Steggs
ID: 18028536
Replace & with &
0
 
LVL 19

Accepted Solution

by:
VoteyDisciple earned 400 total points
ID: 18028743
ANYWHERE in an HTML page you have an & it must be written as &

Thus the following varieties of HTML are all correct:
<a href="useful.php?foo=1&amp;bar=2">Ampersand-tastic!</a>
<input type="text" value="Hello &amp; Goodbye" />
<p>"You &amp; I" is more correct than "I &amp; You"</p>


Of course, when actually typing a URL into the address bar of your browser, that's not HTML.  A regular & is correct.  It's just that the browser when interpreting any chunk of HTML will treat & as the beginning of an HTML entity, so you've got to spell it all out.

Now, since you've said you're using PHP and MySQL I imagine you're selecting these data from the database, in which case all you really need to do to make sure it's correct is call htmlentities():

Instead of   echo $string;   you'd do   echo htmlentities($string);   and PHP will do all the conversions for you (including quote marks and other stuff that can screw up a page)


0
 

Author Comment

by:a466-ub52
ID: 18174563
Wow!!  Thanks... :) : )
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

CSS3 Custom checkboxes This article shows how to style the checkbox form element using only CSS. Works in: Chrome, FF, Safari, Opera, IE9+ Uses modernizr.js to check for :checked pseudo class, falling back to plain old checkboxes (IE8 and bel…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question