Foros del Web » Programando para Internet » PHP »

Error que no se identificar ...

Estas en el tema de Error que no se identificar ... en el foro de PHP en Foros del Web. Saludos ... Perdonad de nuevo, pero me urge solucionar este error, ue no se porque me sale. Cita: Modificar Noticia Warning: mysql_query() [ http://www.mysql.com/doc]: You ...
  #1 (permalink)  
Antiguo 04/04/2008, 08:56
 
Fecha de Ingreso: agosto-2003
Mensajes: 324
Antigüedad: 20 años, 8 meses
Puntos: 1
Error que no se identificar ...

Saludos ...
Perdonad de nuevo, pero me urge solucionar este error, ue no se porque me sale.
Cita:


Modificar Noticia

Warning: mysql_query() [http://www.mysql.com/doc]: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 in /home/ggroup/public_html/noticias/noticiamver.php on line 66

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/ggroup/public_html/noticias/noticiamver.php on line 67
Os indico el código de la página ... (los datos estan bien configurados, en cuanto a usuario, clave ..)

Código HTML:
<?php include ('seguridad.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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ggroup .-</title>
<link href="../css/Estilo.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
<script>
function envia(pag){
	document.editanoticia.action = pag
	document.editanoticia.submit()
}
</script>
</head>
<body>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr><td><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="150"><a href="../index.php" target="_self"><img src="../imagenes/logoggroup.gif" width="150" height="87" border="0" /></a></td>
                  <td width="640" align="right" valign="top" background="../imagenes/fondosuperior.jpg"><div align="left"></div></td>
        </tr>
            </table></td></tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr valign="top">
          <td width="125" class="TablaContenedorMenu"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr><td>&nbsp;</td></tr>
			  <tr>
                <td><a href="noticias.php" target="_self" class="menun">Zona Noticias</a></td>
              </tr>
              <tr>
                <td>Nueva<br /></td>
              </tr>
              <tr>
                <td><br /></td>
              </tr>
              <tr>
                <td><a href="salir.php" target="_self" class="menun">Salir</a></td>
              </tr>
              <tr>
                <td><br /></td>
              </tr>
          </table></td>
            <td width="20" class="TablaSeparacion"><br /></td>
          <td class="TablaContenidoCenteral"><br />
            <p>Modificar Noticia<br />
                <?php
   	//////////////////////////////////////////
//  CONEXION CON LA BASE DE DATOS       //
//     sustituir por un a funcion       //
	$link = mysql_connect('localhost', 'ggroup', 'casiopea') or die('Error conectando con el servidor.');
	$db = mysql_select_db('ggroup_noticias', $link) or die ('No se puede conectar con la base de datos.');
//////////////////////////////////////////

	$q = 'select * from noticias where NoticiaID= ' . $noticiaid;
	$result=mysql_query($q,$link);
	$reg = mysql_fetch_row($result);
		?>
            </p>
            <form  name="editanoticia" action='noticiaprocm.php' method='post' id="editanoticia">
<table>
<tr>
    <td>Orden:</td>
    <td><input type="text" name="orden" size="20" maxlength="30" id="orden" value="<?php echo $reg[1];?>"/></td>
  </tr>
  <tr>
    <td>Titulo:</td>
    <td><input type="text" name="titulo" size="20" maxlength="50" id="titulo" value="<? echo $reg[2];?>"/></td>
  </tr>
  <tr>
    <td width="120" valign="top">Contenido:</td>
    <td><textarea name="contenido" cols="50" rows="10" id="contenido"><?php echo $reg[3];?> </textarea></td>
  </tr>
</table>
<input type="hidden" name='nid' id='nid' value="<?php echo $reg[0];?>" />
<div align="right">
                <input name="bCancelar" type="button" id="bCancelar" onclick="javascript:history.back();" value="Cancelar"/>
                <input name="bBorrador" type="button" id="bBorrador" onclick="envia('noticiaprocm.php');" value="Guardar"/>
                <?php if($reg[0] == 1){
				echo "<input name=\"bEliminar\" type=\"button\" id=\"bEliminar\" onclick=\"envia('noticiaprocb.php');\" value=\"Eliminar2\"/>";
				}?>
				<input name="bEliminar" type="button" id="bEliminar" onclick="envia('noticiaprocb.php');" value="Eliminar"/>
              </div>

                <div align="left"><strong>Ayuda sobre contenidos.</strong><br />
                  - Puede usar c&oacute;digo HTML dentro de los campos T&iacute;tulo y Contenido.<br />
                  Por ejemplo: Si desea resaltar la palabra “ggroup”, podría conseguirlo mediante la inclusión del c&oacute;digo (eliminar espacios en blanco) <em>< span class="ggroupNoticias">GGroup< /span> </em><br />
                  - El campo orden determina la posici&oacute;n que ocupar&aacute; en el conjunto de las Noticias. Los valores 1, 2 y 3 están reservados a las tres columnas iniciales, de izquierda a derecha, respectivamente. Estos contenidos (1,2 y 3), s&oacute;lo podr&aacute;n editarse, nunca ser eliminados). </div>
              </div>
            </form></td>
        </tr>
      </table><bR /><BR />
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td class="TablaCopyRightNoticias"><a href="noticias/indexnoticias.php" target="_top" class="enlacenoticias">G.Group</a>.
            Pol. Industrial El Trocadero. Telf.:856 21 02 85. Fax:856 21 30 50</td>
        </tr>
</table>

      
    </td>
  </tr>
</table>
</td>
</tr>
<tr></tr>
</table>
</body>
</html> 
El archivo que lleva el include es:
Código PHP:
<?php
//Inicio la sesión
session_start();

//COMPRUEBA QUE EL USUARIO ESTA AUTENTIFICADO
if ($_SESSION['autentificado'] != 'SI') {
    
//si no existe, envio a la página de autentificacion
    
header('Location: indexnoticias.php');
    
//ademas salgo de este script
    
exit();
}    
?>

Gracias
  #2 (permalink)  
Antiguo 04/04/2008, 08:57
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Re: Error que no se identificar ...

Prueba esto:
Código PHP:
        $q 'select * from noticias where NoticiaID= ' $noticiaid;
    
$result=mysql_query($q,$link) or die( "Error en query: $q, error: " mysql_error() );
    
$reg mysql_fetch_row($result); 
Saludos.
  #3 (permalink)  
Antiguo 04/04/2008, 09:00
 
Fecha de Ingreso: agosto-2003
Mensajes: 324
Antigüedad: 20 años, 8 meses
Puntos: 1
Re: Error que no se identificar ...

Gracias por la rapidez ...
El resultado es ...

Cita:
Parse error: syntax error, unexpected ':' in /home/ggroup/public_html/noticias/noticiamver.php on line 66
  #4 (permalink)  
Antiguo 04/04/2008, 09:03
okram
Invitado
 
Mensajes: n/a
Puntos:
Re: Error que no se identificar ...

$noticiaid es una variable que viene de la URL? o donde la defines? Al parecer el error es porque esa variable está llegando vacía y se genera una consulta de tipo:

Código:
select * from noticias where NoticiaID=
lo cuál es incorrecto.

Si viene de la URL (pagina.php?noticiaid=4), prueba poniendo
Código PHP:
$q 'select * from noticias where NoticiaID= ' $_GET['noticiaid']]; 
http://www.php.net/manual/es/security.globals.php

Saludos,
  #5 (permalink)  
Antiguo 04/04/2008, 09:05
 
Fecha de Ingreso: agosto-2003
Mensajes: 324
Antigüedad: 20 años, 8 meses
Puntos: 1
Re: Error que no se identificar ...

OK .. ya lo tengo .. más o menso hice eso ..
Cita:
$noticiaid = $_GET['noticiaid'];
Muchas gracias .. no muchisimas...
  #6 (permalink)  
Antiguo 04/04/2008, 09:07
okram
Invitado
 
Mensajes: n/a
Puntos:
Re: Error que no se identificar ...

Deberías validar de algún modo. Si esa variable no se define en la URL obtendrás el mismo error. Usa funciones como empty() y mysql_real_escape_string() para agregar seguridad a tu aplicación.

Saludos,
  #7 (permalink)  
Antiguo 04/04/2008, 09:10
 
Fecha de Ingreso: agosto-2003
Mensajes: 324
Antigüedad: 20 años, 8 meses
Puntos: 1
Re: Error que no se identificar ...

Muchas gracias... Lo tendre en cuenta, y en cuanto tenga un "hueco" intento implementarlo ...
De nuevo miles y miles de gracias ....En breve sé que volveré a preguntar y ésto da confianza de respaldo.

Muchas muchas gracias
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 05:12.