Foros del Web » Programando para Internet » PHP »

Evitar diagonal invertida antes de las comillas

Estas en el tema de Evitar diagonal invertida antes de las comillas en el foro de PHP en Foros del Web. Hola a todos. Bien, lo que sucede es que tengo un Blog en Blogger, y como sabrán este no acepta emoticonos, por lo que hice ...
  #1 (permalink)  
Antiguo 26/07/2007, 23:19
Avatar de hey_alan  
Fecha de Ingreso: diciembre-2006
Ubicación: México
Mensajes: 348
Antigüedad: 17 años, 3 meses
Puntos: 8
Evitar diagonal invertida antes de las comillas

Hola a todos.

Bien, lo que sucede es que tengo un Blog en Blogger, y como sabrán este no acepta emoticonos, por lo que hice un script aparte para colocar el texto de las entradas y este automaticamente me "convierta" los emoticonos.

El código funciona y todo, pero el problema es que me agrega una diagonal invertida "\" antes de las comillas que hubiese puesto en el formulario.

Es decir, que si en el texto que quiero convertir pongo algo como:

Hola mi nombre es Alan, y uso "comillas"

Al convertir el texto sale como:

Hola mi nombre es Alan, y uso \"comillas\"

Supongo que ya saben de lo que estoy hablando, sé que esas barras las pone como precaución el programa, pero no se si hay manera de evitarlo. El código que estoy usando es:

Código PHP:
<html>

<head>
  <title></title>
</head>

<body>
<center>
<form action="convertir.php" method="post">
<p>Introduce el texto a convertir</p>
<textarea name="entrada" cols="80" rows="12"></textarea><br />
<input type="submit" name="Submit" value="Enviar" />
</form>
<p>Texto transformado:</p>
<textarea cols="80" rows="12">
<?php
if ($_POST["entrada"]){

$entrada=$_POST["entrada"];

$bbcode = array(

':admiracion:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/admiracion.gif" alt="" />',
':confundido:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/confundido.gif" alt="" />',
':ojosarriba:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/ojosarriba.gif" alt="" />',
':what:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/what.gif" alt="" />',
':interrogativo:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/interrogativo.gif" alt="" />',
':lentes:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/lentes.gif" alt="" />',
':bravo:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/bravo.gif" alt="" />',
':lloron:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/lloron.gif" alt="" />',
':estupefacto:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/estupefacto.gif" alt="" />',
':fuck:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/fuck.gif" alt="" />',
':trovador:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/trovador.gif" alt="" />',
':risa:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/risa.gif" alt="" />',
':enamorado:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/enamorado.gif" alt="" />',
':enfadado:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/enfadado.gif" alt="" />',
':nothingtosay:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/nothingtosay.gif" alt="" />',
':estrellado:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/estrellado.gif" alt="" />',
':llorando:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/llorando.gif" alt="" />',
':aguitado:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/aguidado.gif" alt="" />',
':bajoestima:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/bajoestima.gif" alt="" />',
':mafioso:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/mafioso.gif" alt="" />',
':arnold:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/arnold.gif" alt="" />',
':silbando:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/silbando.gif" alt="" />',
':1lugar:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/1lugar.gif" alt="" />',
':2lugar:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/2lugar.gif" alt="" />',
':3lugar:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/3lugar.gif" alt="" />',
':migrana:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/migrana.gif" alt="" />',
':XD:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/XD.gif" alt="" />',
':xX:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/xX.gif" alt="" />',
':wink:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/wink.gif" alt="" />',
':ohmy:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/ohmy.gif" alt="" />',
':lengua:' => '<img src="http://www.myimagehub.com/files/5684/albums/emoticonos/tongue.gif" alt="" />',


);

function 
transformarBB($texto){
$search=array_keys($GLOBALS['bbcode']);
$texto=str_replace($search$GLOBALS['bbcode'], $texto);
return 
$texto;
}

$entrada transformarBB($entrada);

echo 
$entrada;

}
?>
</textarea>
</center>
</body>

</html>

Muchas gracias de antemano
__________________
Alan Marth Media

Diseño web y Publicidad en Morelia, Michoacán
  #2 (permalink)  
Antiguo 27/07/2007, 07:22
AlvaroG
Invitado
 
Mensajes: n/a
Puntos:
Re: Evitar diagonal invertida antes de las comillas

Tu problema es causado por las comillas mágicas.

Y se soluciona temporalmente con stripslashes.


Saludos.
  #3 (permalink)  
Antiguo 27/07/2007, 10:30
Avatar de hey_alan  
Fecha de Ingreso: diciembre-2006
Ubicación: México
Mensajes: 348
Antigüedad: 17 años, 3 meses
Puntos: 8
Re: Evitar diagonal invertida antes de las comillas

Muchas gracias, me ha funcionado perfectamente
__________________
Alan Marth Media

Diseño web y Publicidad en Morelia, Michoacán
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:20.