944,208 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 2831
  • PHP RSS
Oct 28th, 2007
0

Page/Character Encoding Tips

Expand Post »
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>
Similar Threads
Reputation Points: 6
Solved Threads: 19
Posting Whiz in Training
fatihpiristine is offline Offline
283 posts
since Sep 2007
Nov 1st, 2007
0

Re: Page/Character Encoding Tips

Wouldn't it be a better idea to use utf8?
Reputation Points: 13
Solved Threads: 2
Junior Poster
php_daemon is offline Offline
138 posts
since Aug 2006
Nov 1st, 2007
0

Re: Page/Character Encoding Tips

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.
Reputation Points: 6
Solved Threads: 19
Posting Whiz in Training
fatihpiristine is offline Offline
283 posts
since Sep 2007
Nov 1st, 2007
0

Re: Page/Character Encoding Tips

I bet it does and thanks for sharing. I've just dropped in another hint in case it doesn't work for someone.
Reputation Points: 13
Solved Threads: 2
Junior Poster
php_daemon is offline Offline
138 posts
since Aug 2006
Nov 1st, 2007
0

Re: Page/Character Encoding Tips

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'");
Reputation Points: 6
Solved Threads: 19
Posting Whiz in Training
fatihpiristine is offline Offline
283 posts
since Sep 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: MySQL require_once stopping script workin?
Next Thread in PHP Forum Timeline: Parse Error Plz Help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC