Solved

unescaped & or unknown entity "&..."

Posted on 2006-11-28
3
563 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
3 Comments
 
LVL 30

Expert Comment

by:Steggs
Comment Utility
Replace & with &
0
 
LVL 19

Accepted Solution

by:
VoteyDisciple earned 400 total points
Comment Utility
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
Comment Utility
Wow!!  Thanks... :) : )
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Creating a CSS block that only applies to printing By default, all of your CSS applies to every possible view of your page - whether on screen, printed, landscape, touch-screen, or whatever.  You can, however, add CSS that only applies under certai…
When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
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 …

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now