dflow Posted January 4, 2010 Share Posted January 4, 2010 im using <?php mysql_query("SET NAMES 'utf8'")?> i want the select list to show country names in hebrew for example on this page: <?php require_once('../Connections/international.php'); ?> <?php $CatID=intval($_GET['CatID']); header('Content-type: text/html; charset=UTF-8') ; ?> <?php mysql_query("SET NAMES 'utf8'")?> <?php #### Roshan's Ajax dropdown code with php #### Copyright reserved to Roshan Bhattarai - nepaliboy007@yahoo.com ?> <?php $dbconnection = mysql_connect ("localhost", "root", "") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("international", $dbconnection) or die("Couldn't open database: ".mysql_error()); if (isset($CatID)) { } switch ($CatID) { case 0: $result = mysql_query("SELECT country_list.CountryID,country_list.CountryName,country_list.CountryName_heb from country_list WHERE CategoryID = '".$_GET['CatID']."'"); break; case 1: $result = mysql_query("SELECT country_list.CountryID,country_list.CountryName,country_list.CountryName_heb from country_list WHERE CategoryID = '".$_GET['CatID']."'"); break; case 2: $result = mysql_query("SELECT country_list.CountryID,country_list.CountryName,country_list.CountryName_heb from country_list WHERE CatID2 = '".$_GET['CatID']."'"); break; case 3: $result = mysql_query("SELECT country_list.CountryID,country_list.CountryName,country_list.CountryName_heb from country_list WHERE CatID3 = '".$_GET['CatID']."'"); break; case 4: $result = mysql_query("SELECT country_list.CountryID,country_list.CountryName,country_list.CountryName_heb from country_list WHERE CatID4 = '".$_GET['CatID']."'"); break; case 5: $result = mysql_query("SELECT country_list.CountryID,country_list.CountryName,country_list.CountryName_heb from country_list WHERE CatID5 = '".$_GET['CatID']."'"); break; } $row_result = mysql_fetch_assoc($result); $totalRows_result = mysql_num_rows($result); ?> <select name="state" onchange="getCity(<?php echo $CatID;?>,this.value)" width="220px"> <option>בחרו</option> <?php while($row_result=mysql_fetch_assoc($result)) { ?> <option value="<?php echo $row_result['CountryID']; ?>"><?php echo $row_result['CountryName_heb']; ?></option> <?php } ?> </select> <?php mysql_free_result($result); ?> Quote Link to comment https://forums.phpfreaks.com/topic/187148-problems-with-set-names-utf8-not-working-in-select-list-for-non-latin/ Share on other sites More sharing options...
premiso Posted January 4, 2010 Share Posted January 4, 2010 Well for one, you are not connecting to the Database first. You are connecting after. If you were to have: <?php mysql_query("SET NAMES 'utf8'") or trigger_error("Query Failed (UTF8): " . mysql_error()); ?> It would probably tell you as such. Put that after you make the connection and select the database and it should work. If that is not what you are after, please elaborate on how it is not working. Quote Link to comment https://forums.phpfreaks.com/topic/187148-problems-with-set-names-utf8-not-working-in-select-list-for-non-latin/#findComment-988278 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.