techker Posted September 7, 2012 Share Posted September 7, 2012 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> Quote Link to comment Share on other sites More sharing options...
Christian F. Posted September 8, 2012 Share Posted September 8, 2012 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 (). Quote Link to comment Share on other sites More sharing options...
fenway Posted September 8, 2012 Share Posted September 8, 2012 This is a mysql forum -- we don't *ever* need to see a JS function. Quote Link to comment Share on other sites More sharing options...
Christian F. Posted September 8, 2012 Share Posted September 8, 2012 Hmm... You're right. Think this might have been posted in the wrong section, even if it's a bit hard to say exactly what the problem is at this point. Quote Link to comment Share on other sites More sharing options...
techker Posted September 8, 2012 Author Share Posted September 8, 2012 the mysql_set_charset('iso-8859-1',$link); was added for test..but it still does not work. if the data in the database is already set with caracters how can i bring it to utf-8?im confused sorry . Quote Link to comment Share on other sites More sharing options...
Christian F. Posted September 8, 2012 Share Posted September 8, 2012 http://duckduckgo.com/?q=convert+existing+mysql+database+to+utf-8 Quote Link to comment Share on other sites More sharing options...
techker Posted September 8, 2012 Author Share Posted September 8, 2012 well im really lost now..it seems all like server code..anyways..thx for the help.. Quote Link to comment Share on other sites More sharing options...
techker Posted September 9, 2012 Author Share Posted September 9, 2012 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!'; } } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.