Foros del Web » Programando para Internet » PHP »

problemas php con signo '

Estas en el tema de problemas php con signo ' en el foro de PHP en Foros del Web. Hola buenas, Tengo el problema que tengo un formulario textarea con una variable llamada c10 y en el formulario tengo action=post Esta variable lo paso ...
  #1 (permalink)  
Antiguo 10/12/2008, 10:25
Avatar de syntex  
Fecha de Ingreso: noviembre-2002
Ubicación: Cataluña
Mensajes: 978
Antigüedad: 21 años, 5 meses
Puntos: 4
problemas php con signo '

Hola buenas,

Tengo el problema que tengo un formulario textarea con una variable llamada c10 y en el formulario tengo action=post

Esta variable lo paso con tres formularios y todos de ellos los paso como

echo"<input type=hidden name='c10' value='".htmlspecialchars(stripslashes($c10))."'>" ;

Pero me desabilita toda la cadena siguiente al carácter '


Gracias.
__________________
------------------------------------------------
La paciencia es el rey de la ciencia
------------------------------------------------

  #2 (permalink)  
Antiguo 10/12/2008, 10:35
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Respuesta: problemas php con signo '

Lee: http://www.forosdelweb.com/f18/como-...s-bien-588701/

Saludos.
  #3 (permalink)  
Antiguo 10/12/2008, 12:54
Avatar de syntex  
Fecha de Ingreso: noviembre-2002
Ubicación: Cataluña
Mensajes: 978
Antigüedad: 21 años, 5 meses
Puntos: 4
Respuesta: problemas php con signo '

Como ariais para poder gravar en la BD con una variable $c10 para no tener problemas con el signo '.

Código PHP:
<?
if (trim($_POST['c1']) =="" or trim($_POST['c2']) =="" or trim($_POST['c3']) =="" or trim($_POST['c4']) =="" or trim($_POST['c5']) =="" or trim($_POST['c7']) =="" or trim($_POST['c8']) =="" or trim($_POST['c9']) =="" or trim($c10) =="" or trim($_POST['c11']) == or $c12 ==""){
// **************************************************** 1 *********************************************
include("./Anuncios/Anuncio1.php");
}
?>
<?
//******************************* ANUNCIO 2
if (trim($_POST['c1']) !="" and trim($_POST['c2']) !="" and trim($_POST['c3']) !="" and trim($_POST['c4']) !="" and trim($_POST['c5']) !="" and trim($_POST['c7']) !="" and trim($_POST['c8']) !="" and trim($_POST['c9']) !="" and trim($c10) !="" and trim($_POST['c11']) != and $c12 !="" and $SUB != "Pasar al paso 3 .>" and $SUB != "Pasar al paso 4 .>" and $LUPIT == ""){
// **************************************************** 2 *********************************************
include("./Anuncios/Anuncio2.php");
}
?>
<?
//******************************* ANUNCIO 3
if (trim($_GET[c1]) !="" and trim($_POST['c2']) !="" and trim($_POST['c3']) !="" and trim($_POST['c4']) !="" and trim($_POST['c5']) !="" and trim($_POST['c7']) !="" and trim($_POST['c8']) !="" and trim($_POST['c9']) !="" and trim($c10) !="" and trim($_POST['c11']) !="" and trim($c12) !="" and $SUB == "Pasar al paso 4 .>" and $SUB1 !="" and trim($_POST['p1']) !="" and trim($_POST['p1']) == trim($_POST['p2'])  and $SEGURO ==  strtolower($_POST[COD]) and $_GET[ZZ] == ""){
include(
"./Anuncios/Enviar_correo.php");
}
?>
Anuncio 1 (con el primer formulario donde esta el textarea con la variable $c10
Código PHP:
echo"</form><form action='' method='post' id='Form1'>";
echo
"<input type=hidden name='a' value='$a'>";
echo
"<input type=hidden name='c' value='$c'>";
echo
"<input type=hidden name='len' value='$len'>";
echo
"<input type=hidden name='c1' value='".$_GET[c1]."'>";
echo
"<input type=hidden name='cc1' value='".$_GET[cc1]."'>";
echo
"<input type=hidden name='AnDe' value='".$_GET[AnDe]."'>";
echo
"<input type=hidden name='MODOS' value='$MODOS'>";
echo
"<td valign=top><div align=right><FONT SIZE=2 COLOR=#DB5E0D><b>Descripción.: <td valign=top><textarea name=\"c10\" cols=\"60\" rows=\"10\" $CAMPO>".htmlspecialchars(stripslashes($c10))."</textarea><tr>";
echo
"<td style=\"border:solid 1px #cccccc;\" colspan=10 bgcolor=#f1f1f1><div align=left>
    <input type='submit' value='Siguiente .>' name='SI' $CAMPO onclick=\"submitForm();\">
    <input type='reset' value='Resetear .>' name='' $CAMPO>
    <tr>"
;
echo
"</form>"
Anuncio 2 (con el segundo formulario
Código PHP:
echo "</form>";
echo
"<form action='' method='post' enctype='multipart/form-data'>";
echo
"<input type=hidden name='a' value='$a'>";
echo
"<input type=hidden name='len' value='$len'>";
echo
"<input type=hidden name='c' value='$c'>";
echo
"<input type=hidden name='cc1' value='$cc1'>";
echo
"<input type=hidden name='c1' value='$c1'>";
echo
"<input type=hidden name='c2' value='".htmlspecialchars(stripslashes($c2))."'>";
echo
"<input type=hidden name='c3' value='".htmlspecialchars(stripslashes($c3))."'>";
echo
"<input type=hidden name='c4' value='$c4'>";
echo
"<input type=hidden name='c5' value='$c5'>";
echo
"<input type=hidden name='cc5' value='".htmlspecialchars(stripslashes($cc5))."'>";
echo
"<input type=hidden name='c6' value='$c6'>";
echo
"<input type=hidden name='c7' value='$c7'>";
echo
"<input type=hidden name='c8' value='$c8'>";
echo
"<input type=hidden name='c9' value='".htmlspecialchars(stripslashes($c9))."'>";
echo
"<input type=hidden name='c10' value='".htmlspecialchars(stripslashes($c10))."'>";
echo
"<input type='submit' value='Pasar al paso 3 .>' name='SUB' $CAMPO> 
    <input type='submit' value='<. Atrás' name='SUB' $CAMPO>"
;
echo
"</form>"
Anuncio 3 y gravar en la base de datos
Código PHP:
if(mysql_query("UPDATE venta SET Categoria='$cc1',Subcategoria='$c1',Provincia='$c4',Anuncio='$c8',Nombre='".htmlspecialchars(stripslashes($c2))."',Apellidos='".htmlspecialchars(stripslashes($c3))."',Correo='".strtolower(trim($c7))."',Telefono='".trim($c5)."',Titulo='".htmlspecialchars(stripslashes($c9))."',Descripcion='".$c10."',Precio='".trim($c11)."',Usuario='".strtolower(trim($c7))."',Password='-',Finalizado='Si',Poblacion='".htmlspecialchars(stripslashes($cc5))."',Oculto='$c6',UsuarioEncriptado='".md5(trim(strtolower($c7)))."',PassEncriptado='".md5(trim(strtolower($p1)))."',Avanzado='".$_GET[MODOSSUSI]."',Part_Emp='$AnDe',Nombre_Comercial='".htmlspecialchars(stripslashes($empresa))."',Ref_Producto='$ref',Dto='$dto' WHERE (Id='$IDpx')",$conexion))
    {} 
Me podeis mejorar la variable $c10 para el tipo de carácter '?

Gracias
__________________
------------------------------------------------
La paciencia es el rey de la ciencia
------------------------------------------------

  #4 (permalink)  
Antiguo 10/12/2008, 12:57
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: problemas php con signo '

lo que sucede es que, ademas, usas HTML incorrectamente...

incorrecto
Código HTML:
<tag attr='foo'/> 
correcto
Código HTML:
<tag attr="foo"/> 
osea, se deben usar comillas dobles para los atributos... de ahí la raíz de tus problemas...


espero comprendas (y sea eso), suerte!
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #5 (permalink)  
Antiguo 10/12/2008, 14:07
Avatar de syntex  
Fecha de Ingreso: noviembre-2002
Ubicación: Cataluña
Mensajes: 978
Antigüedad: 21 años, 5 meses
Puntos: 4
Respuesta: problemas php con signo '

Si lo añadire así el html \"\"


Si pero lo que introduzco en el textarea con la variable $c10 y como valor un carácter ' me da problemas.
__________________
------------------------------------------------
La paciencia es el rey de la ciencia
------------------------------------------------

  #6 (permalink)  
Antiguo 10/12/2008, 14:10
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Respuesta: problemas php con signo '

Te da problemas por lo mismo, tienes que pasarlo entre comillas dobles.

Por otro lado vas a tener que usar addslashes() sobre tus variables para prevenir que las comillas dobles y simples te den problemas.

Saludos.
  #7 (permalink)  
Antiguo 11/12/2008, 01:26
Avatar de syntex  
Fecha de Ingreso: noviembre-2002
Ubicación: Cataluña
Mensajes: 978
Antigüedad: 21 años, 5 meses
Puntos: 4
Respuesta: problemas php con signo '

Puedo pasarlas en todos los formularios que pasen asta llegar a grabarlo en la BD con addslashes()?

Entonces remplazo
echo"<input type=hidden name='c10' value='".htmlspecialchars(stripslashes($c10)).">"; por
echo"<input type=hidden name='c10' value='".addslashes($c10).">";

Y en php seria correcto así tambien

echo"<tag attr=\"foo\">";



Gracias.
__________________
------------------------------------------------
La paciencia es el rey de la ciencia
------------------------------------------------


Última edición por syntex; 11/12/2008 a las 01:34
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 09:35.