List:General Discussion« Previous MessageNext Message »
From:-{ Rene Brehmer }- Date:November 3 2004 4:28am
Subject:Re: ampersands in the database fields
View as plain text  
Simple: don't convert it to HTML before inserting it. I used to do that as 
well, but it causes problems when using searches for several reasons, 
mostly because you have to convert the search query to HTML, which takes 
time, and then send the more complex data structure to the server, which 
also takes more time (albeit extremely little difference).

Converting the entries upon retrieval rather than insert is a little bit 
slower, but it pays off in the searches being more reliable.


At 03:14 03-11-2004, leegold wrote:
>The subject title is a sedgeway into my question that may slightly of
>topic but I've asked many sources and don't have an answer yet so I ask
>it here.
>I have a text fields of html marked up content which I render via php.
>Looking at the rendered html page in a text editor I see that ampersands
>all appear as   &   When I select the field via sql I also see &
>I have a pretty standard seach, Fulltext and substring (ie. %keyword%)
>searches. There's an acronym in my content:   NA&SD    and when I try
>searching for this it really mucks up. The Fulltext no matter what I try
>does not get a hit. The substring search will work properly if I put the
>following in the search form:    NA&SD    that works.  But trying
>the substring search with   NA&SD   produces weird results...kinda works
>but strangely and affects the rendering of the search results page.
>So what's the cause of all this? Should I upfront load my db text fields
>differently, or, search them differently - what is the  fix  via mysql
>or php for the ampersand problem?
>Lee G.

Rene Brehmer
aka Metalbunny

If your life was a dream, would you wake up from a nightmare, dripping of 
sweat, hoping it was over? Or would you wake up happy and pleased, ready to 
take on the day with a smile?
References, tools, and other useful stuff...
Check out the new Metalbunny forums at

mysql admin clientsleegold1 Nov
  • Re: mysql admin clientsGleb Paharenko2 Nov
  • Re: mysql admin clientsMartijn Tonies2 Nov
  • Re: mysql admin clientsAndy Davidson2 Nov
    • ampersands in the database fieldsleegold3 Nov
      • Re: ampersands in the database fields-{ Rene Brehmer }-3 Nov
  • Re: mysql admin clientsKaram Chand6 Nov
Re: ampersands in the database fieldsleegold3 Nov