PHP - resolver el error

 
Vista:

resolver el error

Publicado por Nallely (11 intervenciones) el 20/05/2014 21:11:59
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<? include "funciones.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=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>
<?
$con = conectar();
$i = $_GET[id_alerta];
$qry= "select fecha, tema, onomastico, descripcion from alertas where id_alerta=".$i;
echo $qry;
$b = mysql_query($qry,$con) or die(mysql_error());
$row = mysql_fetch_array($b);
?>
<body>
<form action="actualiza_alerta.php" method="post">
<table>
	<tr>
    	<td>Fecha</td>
        <td><input type="text" name="fecha" value="<? echo $row['fecha'];?>" /></td>
    </tr>
    <tr>
    	<td>Onomastico</td>
        <td><input type="text" name="ono" value="<?  echo $row['onomastico'];?>" /></td>
    </tr>
    <tr>
    	<td>Tema</td>
        <td><input type="text" name="tema" value="<?  echo $row['tema'];?>" /></td>
    </tr>
    <tr>
    	<td>Descripcion</td>
        <td><Textarea cols="20" rows="9" name="descripcion"><? echo $row['descripcion'];?></Textarea><input type="hidden"  name="id_alerta" value="<? echo $_GET['id_alerta'];?>" /></td>
    </tr>
</table>
<div align="center">
<input type="submit" value="Cambiar" name="enviar" />
</div>
</form>
<?
if(isset($_POST[enviar])){
	$con= conectar();
	$q="update alertas set fecha='".$_POST[fecha]."', onomastico='".$_POST[ono]."', tema='".$_POST[tema]."', descripcion='".$_POST[descripcion]."' where id_alerta='".$_POST[id_alerta]."'";
	echo $q;
    $r = mysql_query($q, $con) or die(mysql_error());
    ?>
 <script type="text/javascript">
	window.opener.location.reload();
	window.close();
 </script>
<? } ?>
</body>
</html>

------------------------------------------------------------------------------------------------------------------------------------------------------------

Ayuda mi query sale mal, muestra lo siguiente:

select fecha, tema, onomastico, descripcion from alertas where id_alerta=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
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

resolver el error

Publicado por Martha (48 intervenciones) el 20/05/2014 22:56:05
Contando, contando, creo que te sobran unas dobles comillas en:
id_alerta='".$_POST[id_alerta]."'";
Es decir:
id_alerta = " ' . $_POST[id_alerta] . ' " ;
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

resolver el error

Publicado por Nallely (11 intervenciones) el 20/05/2014 23:35:07
No, ese no es el error. Me sale lo mismo. :(
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

resolver el error

Publicado por xve (6935 intervenciones) el 21/05/2014 09:01:33
Hola Nellely, entiendo que los nombres de los campos son correctos, por lo que creo que el problema lo tienes en la variable $i, que no tiene valor...

Puedes hacer un:
1
echo $qry;

para ver que la variable $i sale correctamente?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

resolver el error

Publicado por Nallely (11 intervenciones) el 21/05/2014 18:52:30
Ya le puse un echo $qry, pero así es no sale la variable $i, pero no entiendo por que no me sale.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

resolver el error

Publicado por xve (6935 intervenciones) el 21/05/2014 22:30:35
Ahí esta el problema... en la url esta la variable id_alerta?

algo así: http://dominio/pagina.php?id_alerta=1
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar