Page/Character Encoding Tips

Reply

Join Date: Sep 2007
Posts: 271
Reputation: fatihpiristine has a little shameless behaviour in the past 
Solved Threads: 16
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Page/Character Encoding Tips

 
0
  #1
Oct 28th, 2007
if you are having problems with encoding pages/characters,
try this.


<?php
$servername='localhost';
$dbusername='myusername';
$dbpassword='mypassword';
$dbname='mydatabase';
connecttodb($servername,$dbname,$dbusername,$dbpassword);
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
global $link;
$link=mysql_connect ("$servername","$dbuser","$dbpassword");

if(!$link)
{
die("Could not connect to MySQL");
}
mysql_select_db("$dbname",$link) or die ("could not open database");
}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9" />
<meta http-equiv="expires" content="now" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
</head>
<table>
<?php
$Category_SQL = "select * from mytable";
$Category_Result = mysql_query("SET NAMES 'latin5'");
$Category_Result = mysql_query("SET CHARACTER SET latin5");
$Category_Result = mysql_query("SET COLLATION_CONNECTION = 'latin5_turkish_ci'");
$Category_Result = mysql_query($Category_SQL);

while($Category_Write = mysql_fetch_array($Category_Result))
{
?>
<tr>
<td >&loz; <?php print $Category_Write[1]; ?></td>
</tr>
<?php
}
?>
</table>
Do a favour, leave me alone
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 138
Reputation: php_daemon is an unknown quantity at this point 
Solved Threads: 2
php_daemon php_daemon is offline Offline
Junior Poster

Re: Page/Character Encoding Tips

 
0
  #2
Nov 1st, 2007
Wouldn't it be a better idea to use utf8?
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 271
Reputation: fatihpiristine has a little shameless behaviour in the past 
Solved Threads: 16
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: Page/Character Encoding Tips

 
0
  #3
Nov 1st, 2007
man.. it works already... it is just an example for those ppl who have problem with encoding.
you can change it to utf
Last edited by fatihpiristine; Nov 1st, 2007 at 7:25 pm.
Do a favour, leave me alone
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 138
Reputation: php_daemon is an unknown quantity at this point 
Solved Threads: 2
php_daemon php_daemon is offline Offline
Junior Poster

Re: Page/Character Encoding Tips

 
0
  #4
Nov 1st, 2007
I bet it does and thanks for sharing. I've just dropped in another hint in case it doesn't work for someone.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 271
Reputation: fatihpiristine has a little shameless behaviour in the past 
Solved Threads: 16
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: Page/Character Encoding Tips

 
0
  #5
Nov 1st, 2007
this one works... enough to collation and character set.

$Category_Result = mysql_query("SET NAMES 'latin5'");
$Category_Result = mysql_query("SET CHARACTER SET latin5");
$Category_Result = mysql_query("SET COLLATION_CONNECTION = 'latin5_turkish_ci'");
Do a favour, leave me alone
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC