Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6140695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:09:08+00:00 2026-05-23T18:09:08+00:00

I’ve been learned to keep my data in MySQL as raw as possible. Here’s

  • 0

I’ve been learned to keep my data in MySQL as raw as possible. Here’s an example of how I store content in my MySQL database:

title (VARCHAR, 255) => Références
content (TEXT) => <p>A paragraph about r&eacute;f&eacute;rences...</p>

When I output it to a page, I use htmlentities() on title, but ofcourse not on content. I feel this is the correct way of storing it, since title stores only text and content stores HTML.

However, I now see a limitation to this: when I’m do a fulltext search to match a specific keyword (such as réferences), I need to search both for références AND r&eacute;f&eacute;rences in order to retrieve all results.

And now I’m thinking… What is the correct way to solve this problem?

  • Review the database and store everything with htmlentities? (Don’t want!)
  • Do two searches, one for the keyword without htmlentities and one for the one with? (Doesn’t seem optimal to me…)

Just for the record, here’s my enormous MySQL query, that searches in page, page_content, article, download, member and event, so you have a bit of a picture of what I’m dealing with.

Thanks in advance for your efforts.

$keyword = utf8_decode(mysql_real_escape_string($_POST['keyword']));

SELECT 
    *, 
    sum(score) AS total_score
FROM 
    (
        SELECT 
            "page" as db_table,
            lid,
            sid as page_sid,
            sid,
            hook,
            title,
            meta_keywords,
            meta_description,
            NULL as content,
            NULL as location,
            NULL as company,
            MATCH(title, meta_keywords, meta_description) AGAINST("'.$keyword.'*" IN BOOLEAN MODE) AS score 
        FROM page
        WHERE MATCH(title, meta_keywords, meta_description) AGAINST("'.$keyword.'*" IN BOOLEAN MODE)
    UNION
        SELECT 
            "page_content" as db_table,
            p.lid as lid,
            pc.page_sid as page_sid,
            NULL as sid,
            NULL as hook,
            p.title as title,
            NULL as meta_keywords,
            NULL as meta_description,
            pc.content as content, 
            NULL as location,
            NULL as company,
            MATCH(content) AGAINST("'.$keyword.'*" IN BOOLEAN MODE) AS score 
        FROM page_content pc, page p
        WHERE MATCH(content) AGAINST("'.$keyword.'*" IN BOOLEAN MODE)
        AND p.sid = pc.page_sid     
    UNION
        SELECT 
            "article" as db_table,
            lid,
            NULL as page_sid,
            sid,
            NULL as hook,
            title,
            meta_keywords,
            meta_description,
            content,
            NULL as location,
            NULL as company,
            MATCH(meta_keywords, meta_description, title, content) AGAINST("'.$keyword.'*" IN BOOLEAN MODE) AS score 
        FROM article 
        WHERE MATCH(meta_keywords, meta_description, title, content) AGAINST("'.$keyword.'*" IN BOOLEAN MODE)   
    UNION
        SELECT 
            "download" as db_table,
            lid,
            NULL as page_sid,
            NULL as sid,
            NULL as hook,
            title,
            NULL as meta_keywords,
            NULL as meta_description,
            content,
            NULL as location,
            NULL as company,
            MATCH(title, content) AGAINST("'.$keyword.'*" IN BOOLEAN MODE) AS score 
        FROM download
        WHERE MATCH(title, content) AGAINST("'.$keyword.'*" IN BOOLEAN MODE)
    UNION
        SELECT
            "event" as db_table,
            lid,
            NULL as page_sid,
            NULL as sid,
            NULL as hook, 
            title,
            NULL as meta_keywords,
            NULL as meta_description,
            content,
            location,
            NULL as company,
            MATCH(title, content, location) AGAINST("'.$keyword.'*" IN BOOLEAN MODE) AS score 
        FROM event
        WHERE MATCH(title, content, location) AGAINST("'.$keyword.'*" IN BOOLEAN MODE)  
    UNION
        SELECT
            "member" as db_table, 
            NULL as lid,
            NULL as page_sid,
            NULL as sid,
            NULL as hook, 
            NULL as title,
            NULL as meta_keywords,
            NULL as meta_description,
            NULL as content,
            NULL as location,
            company,
            MATCH(company) AGAINST("'.$keyword.'*" IN BOOLEAN MODE) AS score 
        FROM member
        WHERE MATCH(company) AGAINST("'.$keyword.'*" IN BOOLEAN MODE)   
    ) AS sub_query
WHERE 1=1
GROUP BY page_sid
ORDER BY total_score DESC
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:09:09+00:00Added an answer on May 23, 2026 at 6:09 pm

    You could leave "référence" unescaped in content as well, as it remains correct HTML.

    (As long as the HTML header specifies the encoding to be the same as in the database, supposedly UTF-8:

    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
    

    )

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
i got an object with contents of html markup in it, for example: string
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I have a reasonable size flat file database of text documents mostly saved in
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.