| | |
Page/Character Encoding Tips
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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 >◊ <?php print $Category_Write[1]; ?></td>
</tr>
<?php
}
?>
</table>
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 >◊ <?php print $Category_Write[1]; ?></td>
</tr>
<?php
}
?>
</table>
Do a favour, leave me alone
![]() |
Similar Threads
- force a page character set (PHP)
- Hit counter (JavaScript / DHTML / AJAX)
- Car Dealership Website (Website Reviews)
- JSP, mysql, and character encoding (JSP)
- About <error-page> tag in struts (JSP)
- help: problems with message appearing for ie users (HTML and CSS)
- Uninstalling IE 6 language packs? (Web Browsers)
- IE popup delay (Web Browsers)
Other Threads in the PHP Forum
- Previous Thread: MySQL require_once stopping script workin?
- Next Thread: Parse Error Plz Help
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube






