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 6875369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:18:50+00:00 2026-05-27T04:18:50+00:00

In the admin section of my website’s glossary, I wrote an ajax function which

  • 0

In the admin section of my website’s glossary, I wrote an ajax function which checks the mysql database for existing entries with the same term before the form is being inserted to avoid double entries.

The function works, but only when the term does not contain any foreign language characters. The website’s main language is French, so there’s a lot of these. The database tables are encoded in latin1_swedish_c1 (default).

JS

$('input[id=term]').live('focusout',function(){
        var element = $(this).attr('id');
        var term = $(this).val();
        if(term != ""){
        // alert(term);
        $(this).closest('tr').children().eq(2).load('ajax/term_chk.php', {'term':term}, function(data){
        $(this).html(data);
        });
        }
        });

PHP
term_chk.php calls the following function:

function checkTerm($term)
{
$qry = "select * from trm where term = '".addslashes($term)."' limit 1";
$qry_res = mysql_query($qry);
if(mysql_numrows($qry_res) > 0)
{
    $t = mysql_fetch_assoc($qry_res);
    $checkStr = '<span style="background-color: #F00; padding: 1px 10px">ID '.$t['id'].'</span>';
} else {
    $checkStr = '<span style="background-color: #5BB26B; ; padding: 1px 10px">OK</span>';
}
return $checkStr;
}

Thanks in advance for your help

  • 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-27T04:18:51+00:00Added an answer on May 27, 2026 at 4:18 am

    Three things:

    1. The symptoms might be explained by the character encoding of the webpage. If the webpage is UTF-8 but the MySQL connection character set is Latin-1, for example, then the query will not work because each multi-byte character will be interpreted as a series of characters.
    2. addslashes() is not good enough protection against SQL injection. Use a database-connection-specific function such as mysql_real_escape_string(). Better still, update to PDO or the mysqli library; the mysql library is obsolete.
    3. The name of the collation is latin1_swedish_ci, not latin1_swedish_c1.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the admin section of a website i am building i would like to
I'm currently working on an admin section for a website. The admin can use
I've got a list of products in an admin section of my website. I
The URL for the administration section of my website always starts with Admin/ .
I have a website built with CodeIgniter which, for the admin area, is using
I've just been tasked with abstracting the admin section of a website to its
I am building a data import tool for the admin section of a website
How can i restrict access to the admin/ section of my website? I can't
I'm building a (CakePHP) website with an admin section that allows rich text editing
I'm making a form (html & php) which is part of an admin section

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.