Foros del Web » Programando para Internet » PHP »

Espaciado entre parrafos

Estas en el tema de Espaciado entre parrafos en el foro de PHP en Foros del Web. Saludos, tengo un problemita y es que extrayendo desde la base de datos no me reconoce el espaciado en textos entre parrafos.. me deberia salir ...
  #1 (permalink)  
Antiguo 05/02/2008, 07:47
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Espaciado entre parrafos

Saludos,
tengo un problemita y es que extrayendo desde la base de datos no me reconoce el espaciado en textos entre parrafos..
me deberia salir algo asi

parrafo1

parrafo2

y me sale parrafo1 parrafo2
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #2 (permalink)  
Antiguo 05/02/2008, 08:01
Avatar de diego_fallout  
Fecha de Ingreso: septiembre-2005
Mensajes: 10
Antigüedad: 18 años, 7 meses
Puntos: 0
Re: Espaciado entre parrafos

seguramente lo estas guardando desde un form con un textarea, antes de guardarlo en la DB tenes q usar la siguiente funcion:

nl2br
http: //ar2.php.net/nl2br
Saludos
  #3 (permalink)  
Antiguo 05/02/2008, 08:14
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Re: Espaciado entre parrafos

ok lo hice y me da un error...

fijate el form
Código PHP:
<form action="<?php echo $editFormAction?>" method="post" enctype="multipart/form-data" name="form1" onSubmit="MM_validateForm('descripcion','','R');return document.MM_returnValue">
                <table align="center">
                  <tr valign="middle">
                    <td width="98" align="left" nowrap class="text1">Titulo</td>
                    <td width="267" align="left"><input name="titulo" type="text" class="todopanel" id="titulo" value="<?php echo $row_Recordset1['titulo']; ?>"></td>
                  </tr>
                  <tr valign="middle">
                    <td height="21" align="left" nowrap class="text1">Fecha</td>
                    <td align="left"><input name="fecha" type="text" class="todopanel" id="fecha" value="<?php echo $row_Recordset1['fecha']; ?>"></td>
                  </tr>
                  <tr valign="middle">
                    <td height="147" align="left" valign="top" nowrap class="text1">Contenido</td>
                    <td align="left" valign="middle"><textarea name="contenido" cols="50" rows="10" class="todopanel" id="contenido" ><?php echo nl2br $row_Recordset1['contenido']; ?></textarea></td>
                  </tr>
                  <tr valign="middle" class="text1">
                    <td colspan="2" align="left" nowrap class="Estilo8">Actualizar Imagen? <span class="todopanel"> Si
                        <input name="opcion" type="radio" value="1">
                      /No
                      <input name="opcion" type="radio" value="0" checked>
                      <input name="imagen" type="hidden" class="todopanel" value="<?php echo $row_Recordset1['imagen']; ?>" size="32">
                      <input name="imagen" type="file" class="todopanel" id="imagen">
                    </span></td>
                    </tr>
                  <tr valign="middle">
                    <td align="left" nowrap class="text1">Video URL</td>
                    <td align="left" nowrap class="Estilo8"><input name="video" type="text" class="todopanel" id="video" value="<?php echo $row_Recordset1['video']; ?>"></td>
                  </tr>
                  <tr valign="middle">
                    <td colspan="2" align="center" nowrap>&nbsp;</td>
                    </tr>
                  <tr valign="middle">
                    <td colspan="2" align="left" nowrap> <input type="hidden" name="MM_update" value="form1">
                      <input type="hidden" name="id" value="<?php echo $row_Recordset1['id']; ?>"></td>
                    </tr>
                  <tr valign="middle">
                    <td align="left" nowrap>&nbsp;</td>
                    <td align="left"><input name="submit" type="submit" class="todopanel" value="Actualizar noticias">                      </td>
                  </tr>
                </table>
                </form> </p>
y la cabezera
Código PHP:
<?php require_once('../Connections/azimut.php'); ?>
<?php
function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {

if (
$_POST['opcion']==1){
$ediciondir'../images2/';  
$uploaddir=$ediciondir;
if (!
is_dir($ediciondir)) {     mkdir($uploaddir0777);    }
move_uploaded_file($_FILES['imagen']['tmp_name'], $uploaddir $_FILES['imagen']['name']);    
$filename $_FILES['imagen']['name'];}
else {
$filename $_POST['imagen'];
}





  
$updateSQL sprintf("UPDATE noticias SET titulo=%s, fecha=%s, contenido=%s, imagen=%s, video=%s WHERE id=%s",
                       
GetSQLValueString($_POST['titulo'], "text"),
                       
GetSQLValueString($_POST['fecha'], "text"),
                       
GetSQLValueString($_POST['contenido'], "text"),
                       
GetSQLValueString($filename"text"),
                       
GetSQLValueString($_POST['video'], "text"),
                       
GetSQLValueString($_POST['id'], "int"));

 
mysql_select_db($database_azimut$azimut);
 
$Result1 mysql_query($updateSQL$azimut) or die(mysql_error());

  
$updateGoTo "listado_noticias.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$updateGoTo .= (strpos($updateGoTo'?')) ? "&" "?";
    
$updateGoTo .= $_SERVER['QUERY_STRING'];
  }
 
header(sprintf("Location: %s"$updateGoTo));
}

$colname_Recordset1 "1";
if (isset(
$_GET['id'])) {
  
$colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_azimut$azimut);
$query_Recordset1 sprintf("SELECT * FROM noticias WHERE id = %s"$colname_Recordset1);
$Recordset1 mysql_query($query_Recordset1$azimut) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);
?>
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #4 (permalink)  
Antiguo 05/02/2008, 08:19
Avatar de spider_boy  
Fecha de Ingreso: diciembre-2003
Ubicación: Chile
Mensajes: 1.855
Antigüedad: 20 años, 4 meses
Puntos: 89
Re: Espaciado entre parrafos

Debes encerrar la variable entre paréntesis

nl2br($variable);

nos vemos...
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 18:07.