Solved

unescaped & or unknown entity "&..."

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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
Problem to refer to value 8 82
Little bit of help styling my heading 3 38
CSS style formatting? 2 37
Fix a css menu for width 15 33
Unordered lists (HTML ul tags) are very handy to create menus of all types, shapes and sizes.  All it takes is a little knowledge of CSS and the possibilities are endless. First off, you should know the general format for menus created using the …
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…

730 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