Comentarios sin revisar del artículo: Convertir caracteres UTF-8 con PHP

5 comentarios sin revisar
08/5/09
Excelente...
Por: Vicente López
Después de 2 horas busque y busque por fin lo encontré, muchas gracias por el artículo.



Saludos.
31/8/09
Gracias Gracias Gracias
Por: ttorrentte
Perfecto, llevaba ya un rato enfrascado con lo mismo, no podía hacer consultas con acentos y con esta función se han solucionado, muchas gracias.
04/9/09
Reconocer utf-8
Por: Carlos
Hola amigos de DW. Aprovechando este tema sobre UTF-8 presento una consulta.
Estoy adaptando un libro de visitas que funciona en Flash, cargando variables desde un archivo php. Es conocido, de flash-db.com
El tema es que no sé cómo ni donde escribir dentro del php el código para que reconozca acentos, ñ y otros caracteres especiales.
A continuación el php en cuestión, y desde ya gracias por su ayuda.

<?php

// If you are using an old version of php, remove the next set of lines.
// or use $HTTP_POST_VARS["..."] instead.

$Submit = $_POST["Submit"];
$Nombre = $_POST["nombreV"];
$Email = $_POST["emailV"];
$Barrio = $_POST["barrioV"];
$Comentario = $_POST["comentarioV"];
$NumLow = $_REQUEST["NumLow"];
$NumHigh = $_REQUEST["NumHigh"];

// Replace special characters - you can remove the next 5 lines if wanted.
$Nombre = ereg_replace("[^A-Za-z0-9 ]", "", $Nombre);
$Email = ereg_replace("[^A-Za-z0-9 @.-/']", "", $Email);
$Comentario = ereg_replace("[^A-Za-z0-9 @.-/]", "", $Comentario);
$Barrio = ereg_replace("http://", "", $Barrio);
$Barrio = ereg_replace("[^A-Za-z0-9 @.-/:]", "", $Barrio);

// Remove slashes.
$Nombre = stripslashes($Nombre);
$Email = stripslashes($Email);
$Barrio = stripslashes($Barrio);
$Comentario = stripslashes($Comentario);

// ###################################################################################
// ########## Reading and Writing the new data to the GuestBook Database #############

if ($Submit == "Yes") {

// Next line tells the script which Text file to open.
// La siguiente línea le dice a la secuencia de comandos que el archivo de texto para abrir.
$filename = "GuestBook.txt";

// Opens up the file declared above for reading

$fp = fopen( $filename,"r");
$OldData = fread($fp, 80000);
fclose( $fp );

// Gets the current Date of when the entry was submitted
$Today = (date ("d/m/Y",time()));


// Puts the recently added data into html format that can be read into the Flash Movie.
// You can change this up and add additional html formating to this area. For a complete listing of all html tags
// you can use in flash - visit: http://www.macromedia.com/support/flash/ts/documents/htmltext.htm

$Input = "Nombre: <b>$Nombre</b><br>Barrio: <b><u>$Barrio</u></b><br>Comentarios: <b>$Comentario</b><br><i><font size="-1">Fecha: $Today</font><br><br>.:::.";

/* This Line adds the '&GuestBook=' part to the front of the data that is stored in the text file. This is important because without this the Flash movie would not be able to assign the variable 'GuestBook' to the value that is located in this text file */

$New = "$Input$OldData";

// Opens and writes the file.

$fp = fopen( $filename,"w");
if(!$fp) die("&GuestBook=cannot write $filename ......&");
fwrite($fp, $New, 800000);
fclose( $fp );
}

// ###################################################################################
// ######### Formatting and Printing the Data from the Guestbook to the Flash Movie ##



// Next line tells the script which Text file to open.
// La siguiente línea le dice a la secuencia de comandos que el archivo de texto para abrir.
$filename = "GuestBook.txt";

// Opens up the file declared above for reading

$fp = fopen( $filename,"r");
$Data = fread($fp, 800000);
fclose( $fp );

// Splits the Old data into an array anytime it finds the pattern .:::.
$DataArray = split (".:::.", $Data);

// Counts the Number of entries in the GuestBook
$NumEntries = count($DataArray) - 1;

print "&TotalEntries=$NumEntries&NumLow=$NumLow&NumHigh=$NumHigh&GuestBook=";
for ($n = $NumLow; $n < $NumHigh; $n++) {
print $DataArray[$n];
if (!$DataArray[$n]) {
Print "<br><br><b>No hay mas comentarios</b>";
exit;
}
}
?>
29/10/09
excelente
Por: alvaro
muy bueno me funcionó 100pts saludos
18/11/09
PROBLEMAS CON UNA CONSULTA DESDE PHP
Por: Hector
Bueno mi problema es el siguiente.

Tengo la pagina web de un cliente en la cual el contenido es modificado desde un manejador de contenidos disenado para la pagina. La misma tiene una lista de productos pero al momento de hacer la inclucion de uno con sus caracteristicas cada capo de datos es escrito en las tablas de la base de datos, pero los caracteres son modificados, me refiero a las tildes acentos etc... Esto solo pasa si yo hago las modificaciones de los dastos de un producto determinado desde la herramienta de un manejador de contenido que esta en edit_pro.php, pero si me meto en las tablas de la base de datos por phpMyadmin y realizo las modificaciones de las caracteristicas del producto desde ahi al momento de verlo en la pagina inexplicablemente esta bien. Pero si vuelvo a entrar al manejador, a pesar que se encuentran bien las tablas, si realizo una modificacion desde el edit_pro.php aunque no toque los caracteres, altera todo lo que tenga simbolos.

Intente modificar las meta <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> por otros ISO y la verdad es que no he podido.

Mi interrogante es porque si modifico las tablas directamente en mysql la pagina web ve los caracteres a pesar de ser un php y cuando lo modifico desde el manejador modifica todo el contenido, es decir me altera los caracteres?

Debo cambiar algun lenguaje en el msql?

Debo colocar alguna Meta etiqueta que solvente este problema?

De antemano muchas gracias por cualquier ayuda que me puedan brindar

Alojados en el grupo