Foros del Web » Programando para Internet » PHP »

PHP OO No me sale lo de editar con valor anterior

Estas en el tema de No me sale lo de editar con valor anterior en el foro de PHP en Foros del Web. Hola quiero hacer un editado con el valor de articulo anterior a editar, pero nose como hacerlo he hecho esto y me sale este error ...
  #1 (permalink)  
Antiguo 23/10/2011, 05:32
(Desactivado)
 
Fecha de Ingreso: septiembre-2011
Mensajes: 283
Antigüedad: 12 años, 7 meses
Puntos: 10
No me sale lo de editar con valor anterior

Hola quiero hacer un editado con el valor de articulo anterior a editar, pero nose como hacerlo he hecho esto y me sale este error como lo podria areglar o hacer??
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- DW6 -->
<head>
<link rel="shortcut icon" href="../imagenes/favicon.ico" />
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link rel="stylesheet" href="../3col_leftNav.css" type="text/css" />
<style type="text/css">
<!--
.Estilo1 {color: #000000;
    font-weight: bold;
}
-->
</style>
</head>
<body>
<?php
$username 
$_COOKIE['loggedin'];
if (!isset(
$_COOKIE['loggedin'])) die("Usted no esta conectado, <a href=index.php>click aquí</a> para conectarse.");
echo 
"Usted está conectado $usuario";
?> 
<a href="logout.php">Cerrar sesion</a>
<div id="masthead">
  <h1 id="siteName"><img src="../headerimg.jpg" width="1310" height="188" /></h1>
</div>
<div id="navBar">
  <div id="search">
    <div id="sectionLinks">
      <h3 align="center">MENU</h3>
      <ul>
        <li><a href="../index.php">INICIO</a></li>
        <li><a href="../documentos.php">DOCUMENTOS</a></li>
        <li><a href="../fotos.php">FOTOS</a></li>
        <li><a href="../videos.php">VIDEOS</a></li>
        <li><a href="../contacto.php">CONTACTO</a></li>
        <li><a href="../comentarios.php?pag=1">COMENTARIOS</a></li>
      </ul>
    </div>
        <div id="sectionLinks">
        <h3 align="center">MENU ADMINISTRACION</h3>
        <ul>
        <li><a href="moderacion.php">BORRADO COMENTARIOS</a></li>
        <li><a href="articulos.php">NUEVO ARTICULO </a></li>
        <li><a href="moderacion_articulo.php">ARTICULOS</a></li>
        </ul>
        </div>
    
  </div>
</div>
<!--end navBar div -->
<div id="headlines">
  <div id="advert">
  <h3 align="center">ENLACES</h3>
  
  <li><a href="">Ayuntamiento de Yuncos</a> </li>
  <li><a href="#">B.O.P.</a></li>
  <li><a href="#">Medico Yuncos </a></li>
  </div>
  <div id="advert">
  <h3 align="center">PRENSA</h3>
  <p align="center"><a href="http://eldiadigital.es/sec/toledo/"><img src="../imagenes/eldiaenclm.gif" width="242" height="56" border="0" /></a></p>
  <p align="center"><img src="../imagenes/cabecera_logo.png" width="239" height="46" border="0" /></p>
  </div>
</div>
<!--end headlines -->
<div id="content">
  <div class="feature">
          <div id="content"><img src="../imagenes/contacto.png" width="777" height="33" /></div>
    <h3>&nbsp;</h3>
    <h3>
    <script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
    tinyMCE.init({
        // General options
        mode : "textareas",
        theme : "advanced",
        plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave",

        // Theme options
        theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
        theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
        theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
        theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : true,

        // Example content CSS (should be your site CSS)
        // using false to ensure that the default browser settings are used for best Accessibility
        // ACCESSIBILITY SETTINGS
        content_css : false,
        // Use browser preferred colors for dialogs.
        browser_preferred_colors : true,
        detect_highcontrast : true,

        // Drop lists for link/image/media/template dialogs
        template_external_list_url : "lists/template_list.js",
        external_link_list_url : "lists/link_list.js",
        external_image_list_url : "lists/image_list.js",
        media_external_list_url : "lists/media_list.js",

        // Style formats
        style_formats : [
            {title : 'Bold text', inline : 'b'},
            {title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
            {title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
            {title : 'Example 1', inline : 'span', classes : 'example1'},
            {title : 'Example 2', inline : 'span', classes : 'example2'},
            {title : 'Table styles'},
            {title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
        ],

        // Replace values for the template plugin
        template_replace_values : {
            username : "Some User",
            staffid : "991234"
        }
    });
</script>
<!-- /TinyMCE -->

</head>
<body>
<? $id $_POST['id']?>
<form method="post" action="enviararticulo.php">
    <div>
      <br>Ubicaci&oacute;n:</br>
      <br>
        <label>
        <select name="select">
          <option>inicio</option>
          <option>documentos</option>
          <option>fotos</option>
          <option>videos</option>
          <option>contacto</option>
          <option>comentarios</option>
        </select>
        </label>
        <h3>
          <!-- Gets replaced with TinyMCE, remember HTML in a textarea should be encoded -->
      </h3>

        <div>
            <textarea id="elm1" name="elm1" rows="15" cols="80" style="width: 80%" ><?php echo $file['$id']; ?></textarea>
        </div>

        <br />
        <input type="hidden" name="id" value="<?php echo $fila['id']; ?>"/>
        <input type="submit" name="save" value="Enviar" />
        <input type="reset" name="reset" value="Reset" />
  </div>
</form>

<script type="text/javascript">
if (document.location.protocol == 'file:') {
    alert("The examples might not work properly on the local file system due to security settings in your browser. Please use a real webserver.");
}
</script>
<? 

$id 
$_POST['id2'];

$conexion=mysql_connect("localhost","root","")
or die (
"Algo hiciste mal");
mysql_select_db("iu",$conexion) or die ("algo paso en el select db");
$registros=mysql_query("select * from articulos
                       where id='$_POST[id2]'"
,$conexion) or
  die(
"Problemas en el select:".mysql_error());
if (
$reg=mysql_fetch_array($registros))
{
//en construccion
?>

<div id="siteInfo"><span class="Estilo1">[email protected]</span> | &copy;2011 I.U. DE YUNCOS </div>
<br />
</body>
</html>
Este es el que manda el id del articulo
Código PHP:
<form action="editar_articulo.php" method="post">
<input type="hidden" name="id" value="<?php echo $fila['id']; ?>"/>
<input type="submit" name="submit" value="editar" />
</form>
y aqui el error:
Notice: Undefined variable: file in C:\wamp\www\iuyuncos\yuncos\admin\editar_articulo. php on line 147

Necesito su ayuda. gracias.
  #2 (permalink)  
Antiguo 23/10/2011, 06:26
Avatar de charlyalegret  
Fecha de Ingreso: septiembre-2011
Ubicación: Barcelona
Mensajes: 705
Antigüedad: 12 años, 7 meses
Puntos: 140
Respuesta: No me sale lo de editar con valor anterior

En la linea 147 tienes: <?php echo $file['$id'];
Esta variable no está definida ---- > ¿no será $fila? ¿donde la defines?
  #3 (permalink)  
Antiguo 23/10/2011, 07:28
(Desactivado)
 
Fecha de Ingreso: septiembre-2011
Mensajes: 283
Antigüedad: 12 años, 7 meses
Puntos: 10
Respuesta: No me sale lo de editar con valor anterior

haber si era fila pero sigue dandome el error lo defino en este archivo te paso:
Código PHP:
<?php 

  
$bdconex 
= @mysql_connect("localhost""root"""); 
if (!
$bdconex) { 
echo( 
"<h1>La base de datos no está disponible</h1> " 
"<p>Por si acaso, comprueba que tienes bien los datos de la dirección, el nombre de usuario y la contraseña.</p>" ); 
exit(); 
}
 if (! @
mysql_select_db("iu"$bdconex)){
 echo 
"<h2 align='center'>ERROR3: Imposible localizar la base de datos en este momento</h2>";
 exit();
 }
 
?> 
 <?php
 
  
$resultado 
= @mysql_query("SELECT * FROM articulos order by fecha desc, id desc");
 if (!
$resultado) {
 echo (
"<p> Me temo que te has colado en la query:" mysql_error() . "</p>");
 exit();
 }
 while (
$fila mysql_fetch_array($resultado)) {
 
echo (
"<strong>articulo: </STRONG>" $fila['articulo'] . "<br />");
echo (
"<strong>id: </strong>" .$fila['id']."<br />");


 
?>
Otra cuestion hay manera de sacar la variable pero sin que aya que imprimirla es decir sin el echo??
  #4 (permalink)  
Antiguo 23/10/2011, 10:17
Avatar de charlyalegret  
Fecha de Ingreso: septiembre-2011
Ubicación: Barcelona
Mensajes: 705
Antigüedad: 12 años, 7 meses
Puntos: 140
Respuesta: No me sale lo de editar con valor anterior

no se si será eso, pero el while donde tienes $fila = mysetcetc, no acaba con }

Suerte!
  #5 (permalink)  
Antiguo 23/10/2011, 13:34
(Desactivado)
 
Fecha de Ingreso: septiembre-2011
Mensajes: 283
Antigüedad: 12 años, 7 meses
Puntos: 10
Respuesta: No me sale lo de editar con valor anterior

si pero se cierra mas abajo que no lo copie mira:
Código PHP:
<form action="borrararticulo.php" method="post">
 <input type="hidden" name="id" value="<?php echo $fila['id']; ?>"/>
<input type="submit" name="Submit" value="borrar">
 </form>

<form action="editar_articulo.php" method="post">
<input type="hidden" name="id" value="<?php echo $fila['id']; ?>"/>
<input type="submit" name="submit" value="editar" />
</form>

 <br/>
<?php ?></p>
yo lo que quiero hacer es sacar el articulo y meterlo en el campo de textarea.
  #6 (permalink)  
Antiguo 24/10/2011, 05:15
(Desactivado)
 
Fecha de Ingreso: septiembre-2011
Mensajes: 283
Antigüedad: 12 años, 7 meses
Puntos: 10
Respuesta: No me sale lo de editar con valor anterior

Si teneis otra forma de hacerlo y me quereis ayudar tambien me vale solo quiero que me mande el articulo a editar. gracias
  #7 (permalink)  
Antiguo 24/10/2011, 07:17
(Desactivado)
 
Fecha de Ingreso: septiembre-2011
Mensajes: 283
Antigüedad: 12 años, 7 meses
Puntos: 10
Respuesta: No me sale lo de editar con valor anterior

E encontrado esto en una web pero no se como desarrollarlo ya que no ha de funcionar ya que el formulario no puede estar dentro de php es html entonces nose como sacar los datos y lg ponerlos como en este de la web:

Código PHP:
<? 
//recibimos la variable id enviada en el enlace por GET 
$id=$_GET[id]; 
//conectamos a la base 
$connect=mysql_connect("servidor","nombre de la base","pass")'; 
//Seleccionamos la base 
mysql_select_db("nombre de la base",$connect); 
//hacemos las consultas 
$result=mysql_query("select * from noticias where id_noticia='
$id'" 
,$connect); 
//Una vez seleccionados los registros los mostramos para su edición 
while($row=mysql_fetch_array($result)) 

echo '
<form action="edit.php" method="post"
<
input type="hidden" name="id" value="'.$row[id_noticia].'"><br
Título noticia:<br
<
input type="text" name="titulo" value="'.$row[titulo].'"><br
Autor:<br
<
input type="text" name="autor" value=".$row[autor].'"><br
Categoría:<br
<
input type="text" name="categoria" value='.$row[categoria].'"><br> 
Escriba el articulo<br> 
<textarea name="
articulo" cols="50" rows="10">'.$row[articulo].'</textarea> 
<br> 
< input type="
submit" value="Editar"><br> 
</form> 

mysql_free_result($result) 
mysq_close($connect) 
?>

Etiquetas: html, imagenes, mysql, registro, sql, variables, usuarios, anteriores
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 20:23.