Jump to content

auto suggest charset..


techker

Recommended Posts

hey guys im trying to figure out why my auto suggest div doesn't show my french characters..

 

now the script is really simple..

 

index(form)

 


<form action="V_P.php" method="post" id="search-form" name="search-form" class="pos-rel">
                                   <input type="text" size="25" value="" id="country" onkeyup="suggest(this.value);" onblur="fill();" class="" name="eleve" />
     
      <div class="suggestionsBox" id="suggestions" style="display: none;"> <img src="arrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />
        <div class="suggestionList" id="suggestionsList">   </div>
      </div>
                                    <input type="submit" value="Go" id="search-btn" name="search-btn" class="grey search" />
                                </form>

 

 

and autocomplete.php

 

link = mysql_connect('localhost', '2', '2');
mysql_set_charset('iso-8859-1',$link);
$db_selected = mysql_select_db('2', $link);
if (!$db_selected) { die ('Database access error : ' . mysql_error());}

///Fisscal year
$q3 = "SELECT * FROM  `Settings` ";
$res3 = mysql_query($q3);
$row5 = mysql_fetch_assoc($res3);


$Table= $row5["Fiscale_Etudiant"];
$TableS= $row5["Fiscale_Sortie"];







$q=$_GET['q'];
//$my_data=mysql_real_escape_string($q);







$sql="SELECT Prenom FROM $Table WHERE Prenom LIKE '%$q%' ORDER BY Prenom";
$result = mysql_query($sql);



?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?

if($result)
{
	while ($row = mysql_fetch_array($result))
	{
		//echo htmlentities($row['Prenom'], ENT_QUOTES, 'ISO-8859-1')"\n";
		//echo $row['Prenom']."\n";
		echo htmlentities($row['Prenom'], ENT_QUOTES, 'iso-8859-1')"\n";
	}
}
?>
</body>
</html>

 

Link to comment
Share on other sites

I'm suspecting that this mysql_set_charset('iso-8859-1',$link); is the problem, or at least part of it. Seeing as it's the US flavor of the latin charsets.  You really should be converting your site to use UTF-8, and make sure that everything is sending, expecting, checking and treating all input and output as UTF-8. That way you will not have any issues with regional glyphs or characters.

 

If that doesn't help then we'll need to see more code, and an example of what it "doesn't show". Especially the JS function suggest ().

Link to comment
Share on other sites

ya..lol looking at this post  noticed the code is not the same..i posted an older page..wow

 

this is the autosuggest.php

 

<?php
   $db = new mysqli('localhost', '2' ,'2', '2');

if(!$db) {

	echo 'Could not connect to the database.';
} else {

	if(isset($_POST['queryString'])) {
		$queryString = $db->real_escape_string($_POST['queryString']);

		if(strlen($queryString) >0) {

			$query = $db->query("SELECT Nom,Prenom FROM Etudiant_2013 WHERE Prenom LIKE '$queryString%' LIMIT 10");
			if($query) {
			echo '<ul>';
				while ($result = $query ->fetch_object()) {
         			echo '<li onClick="fill(\''.addslashes($result->Nom).'\');">'.$result->Nom.'</li>';
         		}
			echo '</ul>';

			} else {
				echo 'OOPS we had a problem ';
			}
		} else {
			// do nothing
		}
	} else {
		echo 'There should be no direct access to this script!';
	}
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.