Foros del Web » Programando para Internet » PHP »

Problema al actulizar registro

Estas en el tema de Problema al actulizar registro en el foro de PHP en Foros del Web. Les pongo el codigo, puedo actualizar todos los campos sin problemas menos el dinamico, el cual me graba en blanco el campo text2. Dejo el ...
  #1 (permalink)  
Antiguo 11/03/2006, 10:02
 
Fecha de Ingreso: diciembre-2004
Mensajes: 103
Antigüedad: 19 años, 4 meses
Puntos: 0
Problema al actulizar registro

Les pongo el codigo, puedo actualizar todos los campos sin problemas menos el dinamico, el cual me graba en blanco el campo text2.
Dejo el codigo por si alguien me ayuda.

Código:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="estilo.css">
<script type="text/javascript">

function showimage() {
if (!document.images)
return
document.images.imagen.src=
'imagenes/' + document.formulario.imagen.options[document.formulario.imagen.selectedIndex].value
}</script>
</head>

<body bgcolor="#FFFFFF">
<?
include ("top.php");
?> 
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="20%" valign="top"><?
include ("inicio.php");
?> </td>
    <td width="80%" valign="top"><?

// Listado de noticias

// Armo una conexion al servidor mysql
$coneccion = mysql_connect($host_db, $user_db, $pass_db);
mysql_select_db($base_db, $coneccion);

if ($REQUEST_METHOD<>"POST")
{

// Busco todos las categorias o tipos de noticias disponibles
$sql_tipos = "select * from tipo_noticias order by desc_tipo_noticia ";
$result_tipos = mysql_query($sql_tipos, $coneccion);

// Busco los datos del registro que voy a editar
$sql = "select * from noticias where id_noticia = $id_noticia";
$result = mysql_query($sql, $coneccion);
$myrow=mysql_fetch_array($result);

?> 
      <script language="JavaScript" src="richedit.js"></script>
      <?
$richEdit0 = $myrow[text2];
?> 
      <form method="POST" action="<?php echo $PHP_SELF ?>" name="formulario">
        <table border="0" width="100%">
          <tr> 
            <td width="100%" colspan="2" bgcolor="#DBDBDB" 
height="20"><b>Editar Noticias</b></td>
          </tr>
          <tr> 
            <td width="30%" height="20"> 
              <p aling="right">Categor&iacute;a: 
            </td>
            <td width="70%" height="20"> 
              <select size="1" name="cod_tipo_noticia">
                <?

// Muestro todos las categorias o tipos de noticias para armar la lista desplegable
while($myrow_tipos = mysql_fetch_array($result_tipos))
{
if ($myrow_tipos[id_tipo_noticia] ==
$myrow[cod_tipo_noticia])
{
echo "<option value=$myrow_tipos[id_tipo_noticia]
selected>$myrow_tipos[desc_tipo_noticia]</option>";
}
else
{
echo "<option value=$myrow_tipos[id_tipo_noticia]>$myrow_tipos[desc_tipo_noticia]</option>";
}
}
?> 
              </select>
            </td>
          </tr>
          <tr> 
            <td width="30%" height="20"> 
              <p aling="right">Subt&iacute;tulo superior: 
            </td>
            <td width="70%" height="20"> 
              <input type="text" name="subtitulo" size="32" value="<? echo $myrow[subtitulo]; ?>" maxlength="100">
            </td>
          </tr>
          <tr> 
            <td width="30%" height="20"> 
              <p aling="right"> Titulo: 
            </td>
            <td width="70%" height="20">
              <input type="text" name="titulo" size="32" value="<? echo $myrow[titulo]; ?>" maxlength="50">
            </td>
          </tr>
          <tr> 
            <td width="30%"> 
              <p aling="right">Texto: 
            </td>
            <td width="70%"> 
              <textarea rows="3" name="text1" cols="27"><? echo $myrow[text1];
?></textarea>
            </td>
          </tr>
          <tr> 
            <td width="30%"> 
              <p aling="right">Texto extendido: 
            </td>
            <td width="70%">
              <script language="JavaScript"> <!--
var editor = new EDITOR();
<?
  $richEdit0 = addslashes(preg_replace("/\r|\n/", '', $richEdit0));
?>
editor.create("<? echo $richEdit0; ?>");
//--> </script>
            </td>
          </tr>
          <tr> 
            <td width="30%" height="20">
              <p aling="right">Imagen: 
            </td>
            <td width="70%" height="20"> <?
$imagen = $myrow['imagen'];
$directorio = 'imagenes' ; //aqui se coloca el directorio q queremos listar
$dir = opendir("$directorio") ; //aqui se abre el directorio
echo "<select name=imagen onChange= showimage()> ";
echo "<option value=sin_imagen.png>Sin imagen</option>";
echo "<option selected>$imagen</option>";
while ($file = readdir($dir)) { //aqui es donde leemos el directorio
if ($file != "." && $file != "..") { //esto es para que no nos muestre la salida a "atras"
echo "<option value=$file>$file</option>";
}
}
echo" </select>";
closedir($dir); //aqui cerramos la carpeta
echo"<br><img src=imagenes/$imagen name=imagen onError=this.onerror='null';this.src='blanco.gif'>"; //aqui se mostraran nuestras imagenes seleccionadas
?></td>
          </tr>
          <tr> 
            <td width="30%" height="27"></td>
            <td width="70%" height="27"> 
              <input type="submit" value="Editar" name="envio">
              <input type="hidden" name="id_noticia" value="<? echo $myrow[id_noticia];
?>">
            </td>
          </tr>
        </table>
      </form>
      <p>&nbsp;</p>
      <?
}
else
{

// Actualizamos el registro con los nuevos valores
// Armo el update
$sql = "update noticias set cod_tipo_noticia = '$cod_tipo_noticia',
titulo = '$titulo',
subtitulo = '$subtitulo',
text1 = '$text1',
text2 = '$richEdit0',
imagen = '$imagen'
where id_noticia = $id_noticia ";
$result = mysql_query($sql, $coneccion);

if (!mysql_error())
{
echo "La noticia $nombre ha sido actualizada exitosamente<br>";
}
else
{
echo "ERROR al actualizar la noticia - ". mysql_errno().":". mysql_error()."<br>";
}
}
?></td>
  </tr>
</table>
</body>
</html>
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 23:22.