Sobre cómo guardar texto UTF-8 en japonés usando MySQL y PHP PDF Imprimir Correo electrónico
Software
Escrito por Pablushka   
Domingo 12 de Septiembre de 2010 10:44

Ejemplo:

 
<?php header("Content-type: text/html; charset=utf-8"); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<form id="form" method="post" action="namae.php">
<div>Ingrese un nombre en japonés <input id="txtNombre" name="txtNombre" type="text" value=""></div>
<div><input id="ok" type="submit" value="Ingrear a la base"></div>
 
<?php
mysql_connect("servidor", "usuario", "password") or die(mysql_error());
mysql_select_db("pablushka") or die(mysql_error());
mysql_query("set names 'utf8'");
 
if ($_POST["txtNombre"]!="") {
  mysql_query("insert into japanese_names (namae) values ('". mysql_real_escape_string($_POST["txtNombre"]) ."')") or die(mysql_error());  
}
 
$result = mysql_query("SELECT * FROM japanese_names") 
or die(mysql_error());  
 
echo "<table border='1'>";
echo "<tr> <th>id</th> <th>namae</th> </tr>";
 
while($row = mysql_fetch_array( $result )) {
 
  echo "<tr><td>"; 
  echo $row['id'];
  echo "</td><td>"; 
  echo $row['namae'];
  echo "</td></tr>"; 
} 
echo "</table>";
?>
<div>Buscar en la base<input id="txtBuscar" name="txtBuscar" type="text" value=""></div>
<div><input id="ok" type="submit" value="Buscar"></div>
<?php
$result = mysql_query("SELECT * FROM japanese_names where namae='". mysql_real_escape_string($_POST["txtBuscar"]) ."'") or die(mysql_error());  
 
echo "<table border='1'>";
echo "<tr> <th>id</th> <th>namae</th> </tr>";
 
while($row = mysql_fetch_array( $result )) {
 
  echo "<tr><td>"; 
  echo $row['id'];
  echo "</td><td>"; 
  echo $row['namae'];
  echo "</td></tr>"; 
} 
echo "</table>";
?>
</form>
 
</body>
</html>
 
Bookmark and Share
Última actualización el Domingo 12 de Septiembre de 2010 11:12