This topic is locked

The Final solution for UTF8 Problem

6/7/2008 2:14:35 AM
PHPRunner General questions
E
eng.mjarkas author

hiii all <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=8718&image=1&table=forumtopics' class='bbc_emoticon' alt=':)' />
Finally i found the solution for UTF8 problem
1 --- first open (include/dbconnection.php) file
U will see the function db_connect function like this
[codebox]function db_connect()

{

global $host,$user,$pwd,$errstr,$sys_dbname,$port;

$strhost=$host;

if($port && $port!=3306)

$strhost=$strhost.":".$port;

$conn = mysql_connect($strhost,$user,$pwd);

if (!$conn || !mysql_select_db($sys_dbname,$conn))

{

trigger_error(mysql_error(), E_USER_ERROR);

}

return $conn;

}[/codebox]
Then U should add this three lines only

[codebox]

mysql_query("SET character_set_server='utf8'");

mysql_query("SET NAMES 'utf8'")or die(mysql_error());

mysql_query("SET CHARACTER SET 'utf8'");

[/codebox]
so the function will be like this

[codebox]function db_connect()

{

global $host,$user,$pwd,$errstr,$sys_dbname,$port;

$strhost=$host;

if($port && $port!=3306)

$strhost=$strhost.":".$port;

$conn = mysql_connect($strhost,$user,$pwd);

if (!$conn || !mysql_select_db($sys_dbname,$conn))

{

trigger_error(mysql_error(), E_USER_ERROR);

}

mysql_query("SET character_set_server='utf8'");

mysql_query("SET NAMES 'utf8'")or die(mysql_error());

mysql_query("SET CHARACTER SET 'utf8'");

return $conn;

}[/codebox]
<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=8718&image=2&table=forumtopics' class='bbc_emoticon' alt=':)' /> good bye