Ver Mensaje Individual
  #19 (permalink)  
Antiguo 13/01/2010, 19:56
okawa
 
Fecha de Ingreso: mayo-2009
Mensajes: 69
Antigüedad: 15 años
Puntos: 0
Respuesta: Leer/Insertar comillas campo mysql

Okram me has ayudado mucho y a entender lo que estoy haciendo

Te comento:

1- Insertar texto con " " o ' ' en la BD --> OK

Código PHP:
$titulo_enlace=$_REQUEST['titulo_enlace'];
$texto_enlace=$_REQUEST['texto_enlace'];

$consulta="INSERT INTO enlaces (titulo_enlace, texto_enlace) VALUES ('$titulo_enlace', '$texto_enlace')";
$insertar=mysql_query($consulta,$db) or die(mysql_error()); 
2- Mostrar el texto con " " o ' ' en la web --> OK

Código PHP:
$consulta="SELECT * FROM enlaces ORDER BY id_enlace ASC";
$result=mysql_query($consulta,$db);

print 
"
<table>
<tbody>"
;
while(
$row=mysql_fetch_array($result)) {

print 
"
<tr>
<td>
<a href='"
.$row[url_enlace]."'><img style='width: 80px; height: 88px;' src='".$row[img_enlace]."' alt='".$row[img_enlace]."'/></a>
</td>
<td>
<a href='"
.$row[url_enlace]."'><b>".htmlspecialchars($row[titulo_enlace], ENT_QUOTES)."</a> - </b>".htmlspecialchars($row[texto_enlace], ENT_QUOTES)."
</td>
</tr>
"
;
}
print 
"
</table>
</tbody>
"

3 - Editar texto con " " o ' ' imprimiendolo desde la BD en un campo de un formulario --> OK

Código PHP:
while($row=mysql_fetch_array($result)) {            
print 
"<form action='editar-enlace.php' method='post' enctype='multipart/form-data'>
<p>Título del Enlace<br/>
<input type='text' name='titulo_enlace' size='50' value='"
.htmlspecialchars($row[titulo_enlace], ENT_QUOTES)."'/></p>
<p>Texto del Enlace<br/>
<textarea name='texto_enlace' rows='10' cols='50'>"
.htmlspecialchars($row[texto_enlace], ENT_QUOTES)."</textarea></p>
<p><input type='submit' name='editar' value='Editar'/></p>
</form>"
;


El problema es que los SALTO DE LINEA no me los muestra en el PUNTO 2 pero si los MUESTRA dentro del TEXTAREA en el PUNTO 3.

En el campo de la BD tambien hay los saltos de linea limpios (sin <br > ni caracteres de escape ni nada).

Como puedo hacer para que me muestre en la web tambien los saltos de linea?

Estoy siempre trabajando con codigo limpio.Es decir las comillas NO las guarda NI las imprime de la forma: \' o \" si no que lo hace " o '.

Gracias de nuevo :)