Recent Topics

1 May 23, 2007 03:55    

Hi,

When I try to post anything in Japanese it turns out all ????s. I have tried a few things to solve the problem:
-set everything in _locales.php to utf-8
-set up everything in the b2e blog settings to Japanese local with utf-8 (and set regional and user settings as well to Japanese)
-added the following code (that I found at http://forums.b2evolution.net/viewtopic.php?t=5721) to the _advanced.php file:


/** 
* CREATE TABLE options. 
* 
* Edit those if you have control over you MySQL server and want a more professional 
* database than what is commonly offered by popular hosting providers. 
*/ 
$db_config['table_options'] = ''; // Low ranking MySQL hosting compatibility Default 
// Recommended settings: 
# $db_config['table_options'] = ' ENGINE=InnoDB '; 
// Development settings: 
# $db_config['table_options'] = ' ENGINE=InnoDB DEFAULT CHARSET=utf8 ';
 

I found a thread that I thought might help: http://forums.b2evolution.net//viewtopic.php?p=51837#51837

In the thread, smpdawg says to run the following script:

<?php 
$conn = mysql_connect("localhost", "YOURDBUSER", "YOURDBPASSWORD"); 

$printonly=true; //change this to false to alter on the fly 
$charset="utf8"; 
$collate="utf8_unicode_ci"; 
$altertablecharset=true; 
$alterdatabasecharser=true; 

function PMA_getDbCollation($db) 
{ 
 $sq='SHOW CREATE DATABASE `'.$db.'`;'; 
 $res = mysql_query($sq); 
 if(!$res) echo "\n\n".$sq."\n".mysql_error()."\n\n"; else 
 if($row = mysql_fetch_assoc($res)) 
 { 
  $tokenized = @explode(' ', $row[1]); 
  unset($row, $res, $sql_query); 
  for ($i = 1; $i + 3 < count($tokenized); $i++) 
  { 
   if ($tokenized[$i] == 'DEFAULT' && $tokenized[$i + 1] == 'CHARACTER' && $tokenized[$i + 2] == 'SET') 
   { 
    if (isset($tokenized[$i + 5]) && $tokenized[$i + 4] == 'COLLATE') 
    { 
     return array($tokenized [$i + 3],$tokenized[$i + 5]); // We found the collation! 
    } 
    else 
    { 
     return array($tokenized [$i + 3]); 
    } 
   } 
  } 
 } 
 return ''; 
} 

?> 
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1251<? //remember to change it if needed ?>" /> 
<xmp> 
<?php 

$rs2 = mysql_query("SHOW DATABASES LIKE 'YOURDBTOFIX'"); 

if(!$rs2) echo "\n\n".$sq."\n".mysql_error()."\n\n"; else 
while ($data2 = mysql_fetch_row($rs2)) 
{ 
$db=$data2[0]; 
$db_cha=PMA_getDbCollation($db); 
if ( $db!='mysql' /* &&( $db=='mydb_x' || $db=='mydb_y' ) */ ) // limit to database(s) - $db=='mydb_x' || $db=='mydb_y' || $db=='mydb_z' 
if ( @substr($db_cha[0],0,4)!='utf8' ) // limit to charset 
{ 
 mysql_select_db($db); 
$rs = mysql_query("SHOW TABLES"); 
if(!$rs) echo "\n\n".$sq."\n".mysql_error()."\n\n"; else 
while ($data = mysql_fetch_row($rs)) 
{ 
 $rs1 = mysql_query("show FULL columns from $data[0]"); 
 if(!$rs1) echo "\n\n".$sq."\n".mysql_error()."\n\n"; else 
 while ($data1 = mysql_fetch_assoc($rs1)) 
 { 
  if(in_array(array_shift(split("\\(",$data1['Type'],2)),array( 
//'national char', 
//'nchar', 
//'national varchar', 
//'nvarchar', 
'char', 
'varchar', 
'tinytext', 
'text', 
'mediumtext', 
'longtext', 
'enum', 
'set' 
  ))) 
  { 
   if(substr($data1['Collation'],0,4)!='utf8') // limit to charset 
   { 
    $sq="ALTER TABLE `$data[0]` CHANGE `".$data1['Field'].'` `'.$data1['Field'].'` '.$data1['Type'].' CHARACTER SET binary '.($data1['Default']==''?'':($data1['Default']=='NULL'?' DEFAULT NULL':' DEFAULT \''.mysql_escape_string($data1['Default']).'\'')).($data1['Null']=='YES'?' NULL ':' NOT NULL').';'; 
    if(!$printonly&&!mysql_query($sq)) echo "\n\n".$sq."\n".mysql_error()."\n\n"; 
    else 
    { 
     echo ($sq."\n") ; 
     $sq="ALTER TABLE `$data[0]` CHANGE `".$data1['Field'].'` `'.$data1['Field'].'` '.$data1['Type']." CHARACTER SET $charset ".($collate==''?'':"COLLATE $collate").($data1['Default']==''?'':($data1['Default']=='NULL'?' DEFAULT NULL':' DEFAULT \''.mysql_escape_string($data1['Default']).'\'')).($data1['Null']=='YES'?' NULL ':' NOT NULL').($data1['Comment']==''?'':' COMMENT \''.mysql_escape_string($data1['Comment']).'\'').';'; 
     if(!$printonly&&!mysql_query($sq)) echo "\n\n".$sq."\n".mysql_error()."\n\n"; 
     else echo ($sq."\n") ; 
    } 
   } 
  } 
 } 
 if($altertablecharset) 
 { 
  /* 
  $sq='ALTER TABLE `'.$data[0]."` DEFAULT CHARACTER SET binary"; 
  echo ($sq."\n") ; 
  if(!mysql_query($sq)) echo "\n\n".$sq."\n".mysql_error()."\n\n"; 
  */ 
  $sq='ALTER TABLE `'.$data[0]."` DEFAULT CHARACTER SET $charset ".($collate==''?'':"COLLATE $collate"); 
  echo ($sq.";\n") ; 
    if(!$printonly) 
  if(!mysql_query($sq)) echo "\n\n".$sq."\n".mysql_error()."\n\n"; 
 } 
} 
 if($alterdatabasecharser) 
 { 
  /* 
  $sq='ALTER DATABASE `'.$data2[0]."` DEFAULT CHARACTER SET binary"; 
  echo ($sq."\n") ; 
  if(!mysql_query($sq)) echo "\n\n".$sq."\n".mysql_error()."\n\n"; 
  */ 
  $sq='ALTER DATABASE `'.$data2[0]."` DEFAULT CHARACTER SET $charset ".($collate==''?'':"COLLATE $collate;"); 
  echo ($sq."\n") ; 
    if(!$printonly) 
  if(!mysql_query($sq)) echo "\n\n".$sq."\n".mysql_error()."\n\n"; 
 } 
} 
} 
?> 
</xmp>

He says:

This script will take some time to execute and may even time out if your install of PHP have a short script execution time. When it is finished it will generate a list of ALTER statements that can be used to fix your existing database. All you need to do is copy these commands into the SQL window of phpMyAdmin and execute them.

I changed the 'YOUR' fields to my info like he said, but Safari returns the following error message when I try to run the script that I uploaded to my blog (http://www.en-now.com/b2e/blogs/install/fixcharset.php):

Parse error: syntax error, unexpected T_VARIABLE in /data/12/0/43/39/858854/user/879785/htdocs/b2e/blogs/install/fixcharset.php on line 12

I don't know what it's talking about... I used the same settings that I originally used to install b2evolution.

Anyone know why I'm getting this error? Unfortunately, I don't know anything about PHP... :( Many thanks in advance.


Form is loading...