Solved

unescaped & or unknown entity "&..."

Posted on 2006-11-28
3
566 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

914 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

19 Experts available now in Live!

Get 1:1 Help Now