Respuesta: Editar datos de mysql Lo estoy intentando hacer de esta forma pero no me sale esta bien hecho: 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> </h3> <h3> <?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(); } ?> <? //aki debere de sacar la variables que me mandaran luego al value del articulo $resultado = @mysql_query("SELECT articulo FROM comentarios where id='1'"); if (!$resultado) { echo ("<p> Me temo que te has colado en la query:" . mysql_error() . "</p>"); exit(); } while($fila=mysql_fetch_array($consulta)){ $id = $fila['id']; $nombre = $fila['articulo']; $precio = $fila['fecha']; echo "<p>E producto $nombre ($id) vale $ $precio</p>"; // se obtienen multiples párrafos variando con los datos de los distintos productos }
?> <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> <form method="post" action="enviararticulo.php"> <div> <br>Ubicació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 $fila['articulo']; ?></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>
<div id="siteInfo"><span class="Estilo1">[email protected]</span> | ©2011 I.U. DE YUNCOS </div> <br /> </body> </html> Y me sale este error:
Me temo que te has colado en la query:" . mysql_error() . "
"); exit(); } while($fila=mysql_fetch_array($consulta)){ $id = $fila['id']; $articulo = $fila['articulo']; $fecha = $fila['fecha']; echo "
E producto $nombre ($id) vale $ $precio
"; // se obtienen multiples párrafos variando con los datos de los distintos productos } ?>
y dentro del campo de texto que de editar me sale esto:
Notice: Undefined variable: fila in C:\wamp\www\iuyuncos\iu\admin\editar.php on line 175
La linea 175 de mi codigo es este:
<textarea id="elm1" name="elm1" rows="15" cols="80" style="width: 80%"><?php echo $fila['articulo']; ?></textarea> |