elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: AIO elhacker.NET 2021 Compilación herramientas análisis y desinfección malware


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web
| | |-+  PHP (Moderador: #!drvy)
| | | |-+  Update con php
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Update con php  (Leído 1,978 veces)
DeXon18

Desconectado Desconectado

Mensajes: 25


Ver Perfil
Update con php
« en: 14 Febrero 2012, 21:51 pm »

Hola buenas a todos, tengo un problemilla con un código que ando montando y no tengo manera de que funcione siempre me tira este error:

Citar
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 'de la web, descripcionweb=Descripcion de la web, keywords=Keywords, alexaverifyi' at line 1

y ya no se como ponerlo he probado de todas las formas pero nada, si podrían echarme una mano os lo agradecería.

Código
  1. CREATE TABLE IF NOT EXISTS `maca_configuracion` (
  2.  `idconfiguracion` INT(1) NOT NULL,
  3.  `tituloweb` VARCHAR(255) NOT NULL,
  4.  `descripcionweb` VARCHAR(255) NOT NULL,
  5.  `keywords` VARCHAR(255) NOT NULL,
  6.  `alexaverifyid` VARCHAR(50) NOT NULL,
  7.  `msvalidate` VARCHAR(50) NOT NULL,
  8.  `google` VARCHAR(50) NOT NULL,
  9.  `adminemail` VARCHAR(100) NOT NULL,
  10.  `personalemail` VARCHAR(100) NOT NULL,
  11.  `titulomensajes` VARCHAR(255) NOT NULL,
  12.  `semanal` VARCHAR(50) NOT NULL,
  13.  `horario` VARCHAR(50) NOT NULL,
  14.  `telefono` VARCHAR(20) NOT NULL,
  15.  `tiempo` INT(1) NOT NULL
  16. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Código
  1. <?php
  2. if (!isset($_GET["accion"])){
  3.  
  4.    echo'<form method="post" action="http://www.otros.com/index.php?sección=administracion&amp;area=areaconfig&amp;accion=guardar" enctype="multipart/form-data" >
  5. <fieldset>
  6.                 <legend>Configuraci&oacute;n Web</legend>
  7.                 <div>
  8.                     <label for="tituloweb"><strong>Nombre Web</strong>:</label>
  9.                     <input type="text" id="tituloweb" name="tituloweb" size="20" maxlength="127" value="'.$tituloweb .'"/>
  10.                 </div>
  11.                 <div>
  12.                     <label for="descripcionweb"><strong>Descripcion Web</strong>:</label>
  13. <textarea name="descripcionweb"  id="descripcionweb" cols="4" rows="4"  maxlength="255"wrap="virtual">'.$descripcionweb.'</textarea>
  14.                 </div>
  15. <br /><br /><br /><br />
  16.                 <div>
  17.                     <label for="keywords"><strong>Keywords</strong>:</label>
  18. <textarea name="keywords"  id="keywords" cols="4" rows="4"  maxlength="255"wrap="virtual">'.$keywords.'</textarea>
  19.                 </div>
  20.                 <div>
  21.                     <label for="alexaverifyid"><strong>Alexa ID</strong>:</label>
  22.                     <input type="text" id="alexaverifyid" name="alexaverifyid" size="40" maxlength="50" value="'.$alexaverifyid.'"/>
  23.                 </div>
  24. <div>
  25.                     <label for="msvalidate"><strong>Microsoft Id</strong>:</label>
  26.                     <input type="text" id="msvalidate" name="msvalidate" size="40" maxlength="127" value="'.$msvalidate.'"/>
  27.                 </div>
  28. <div>
  29.                     <label for="google"><strong>Google ID</strong>:</label>
  30.                     <input type="text" id="google" name="google" size="40" maxlength="127" value="'.$google.'"/>
  31.                 </div>
  32. <br /><br />
  33. <div>
  34.                     <label for="adminemail"><strong>Admin Email</strong>:</label>
  35.                     <input type="text" id="adminemail" name="adminemail" size="40" maxlength="127" value="'.$adminemail.'"/>
  36.                 </div>
  37. <div>
  38.                     <label for="personalemail"><strong>Personale Email</strong>:</label>
  39.                     <input type="text" id="personalemail" name="personalemail" size="40" maxlength="127" value="'.$personalemail.'"/>
  40.                 </div>
  41. <div>
  42.                     <label for="titulomensajes"><strong>Titulos Asunto</strong>:</label>
  43.                     <input type="text" id="titulomensajes" name="titulomensajes" size="40" maxlength="255" value="'.$titulomensajes.'"/>
  44.                 </div>
  45. <br /><br />
  46. <div>
  47.                     <label for="semanal"><strong>Trabajo de:</strong>:</label>
  48.                     <input type="text" id="semanal" name="semanal" size="40" maxlength="127" value="'.$semanal.'"/>
  49.                 </div>
  50. <div>
  51.                     <label for="horario"><strong>Horario de</strong>:</label>
  52.                     <input type="text" id="horario" name="horario" size="40" maxlength="127" value="'.$horario.'"/>
  53.                 </div>
  54. <div>
  55.                     <label for="telefono"><strong>Tel&eacute;fono</strong>:</label>
  56.                     <input type="text" id="telefono" name="telefono" size="40" maxlength="127" value="'.$telefono.'"/>
  57.                 </div>
  58. <div>
  59.                     <label for="tiempo"><strong>El Tiempo</strong>:<br/><small> Ahora:'; echo ($seccionweb != 0) ? 'Aemet' : 'El tiempo'; echo '</label>
  60. <select name="tiempo" id="tiempo" size="1">
  61.  <option>Selecciona...</option>
  62.  <option value="0">Aemet</option>
  63.  <option value="1">El Tiempo</option>
  64. </select>
  65.                 </div>
  66. <div>
  67.                 <label for="envio">&nbsp;</label>
  68.                    <input name="enviar" value="Enviar" type="submit" class="boton"/>
  69.               </div>
  70. </form>';
  71.  
  72. }elseif($_GET["accion"]== "guardar" ){
  73.  
  74. // Recojo valores
  75. $tituloweb =$_POST["tituloweb"];
  76. $descripcionweb =$_POST["descripcionweb"];
  77. $keywords =$_POST["keywords"];
  78. $alexaverifyid =$_POST["alexaverifyid"];
  79. $msvalidate =$_POST["msvalidate"];
  80. $google =$_POST["google"];
  81. $adminemail =$_POST["adminemail"];
  82. $personalemail =$_POST["personalemail"];
  83. $titulomensajes =$_POST["titulomensajes"];
  84. $semanal =$_POST["semanal"];
  85. $telefono =$_POST["telefono"];
  86. $tiempo =$_POST["tiempo"];
  87. $idconfiguracion= '0';
  88.  
  89.  
  90. $result =mysql_query("UPDATE ".$prefix."_configuracio SET tituloweb=$tituloweb, descripcionweb=$descripcionweb, keywords=$keywords, alexaverifyid=$alexaverifyid, msvalidate=$msvalidate ,google=$google, adminemail=$adminemail, personalemail=$personalemail, titulomensajes=$titulomensajes, semanal=$semanal, horario=$horario, telefono=$telefono, tiempo=$tiempo WHERE idconfiguracion=='$idconfiguracion'") or die(mysql_error());
  91. }
  92.  
  93. ?>


Un saludo y gracias de antemano


En línea

cassiani


Desconectado Desconectado

Mensajes: 978


« Anterior | Próximo »


Ver Perfil WWW
Re: Update con php
« Respuesta #1 en: 14 Febrero 2012, 23:22 pm »

viendolo por encimita, lo primero que noto es que tu tabla tiene un nombre (`maca_configuracion`) y en tu query usas otro, ademas, no se ve que valor le asignas a $prefix, por lo menos yo no lo veo.
Código:
$result =mysql_query("UPDATE ".$prefix."_configuracio SET ...

- no estas filtrando los datos que recibes por post (ojo con eso).

haz un exit antes de que se ejecute la consulta, para que verifiques como te la esta armando..
Código:
exit("UPDATE ".$prefix."_configuracio SET tituloweb=$tituloweb, descripcionweb=$descripcionweb, keywords=$keywords, 
alexaverifyid=$alexaverifyid,
msvalidate=$msvalidate ,google=$google, adminemail=$adminemail, personalemail=$personalemail, titulomensajes=$titulomensajes,
semanal=$semanal,
horario=$horario, telefono=$telefono, tiempo=$tiempo WHERE idconfiguracion=='$idconfiguracion'");

recuerda que tus campos son NOT NULL..



En línea

DeXon18

Desconectado Desconectado

Mensajes: 25


Ver Perfil
Re: Update con php
« Respuesta #2 en: 15 Febrero 2012, 08:38 am »

Hola cassiani, gracias por tu respuesta.

lo 1º cambie las tablas

Código
  1. CREATE TABLE IF NOT EXISTS `maca_configuracion` (
  2.  `idconfiguracion` INT(1) NOT NULL,
  3.  `tituloweb` VARCHAR(255) CHARACTER SET utf8 DEFAULT NULL,
  4.  `descripcionweb` VARCHAR(255) CHARACTER SET utf8 DEFAULT NULL,
  5.  `keywords` VARCHAR(255) CHARACTER SET utf8 DEFAULT NULL,
  6.  `alexaverifyid` VARCHAR(50) CHARACTER SET utf8 DEFAULT NULL,
  7.  `msvalidate` VARCHAR(50) CHARACTER SET utf8 DEFAULT NULL,
  8.  `google` VARCHAR(50) CHARACTER SET utf8 DEFAULT NULL,
  9.  `adminemail` VARCHAR(100) CHARACTER SET utf8 DEFAULT NULL,
  10.  `personalemail` VARCHAR(100) CHARACTER SET utf8 DEFAULT NULL,
  11.  `titulomensajes` VARCHAR(255) CHARACTER SET utf8 DEFAULT NULL,
  12.  `semanal` VARCHAR(50) CHARACTER SET utf8 DEFAULT NULL,
  13.  `horario` VARCHAR(50) CHARACTER SET utf8 DEFAULT NULL,
  14.  `telefono` VARCHAR(20) CHARACTER SET utf8 DEFAULT NULL,
  15.  `tiempo` INT(1) DEFAULT NULL
  16. );


Lo puse como tu me comentaste:
Código
  1. exit("UPDATE maca_configuracion SET tituloweb=$tituloweb, descripcionweb=$descripcionweb, keywords=$keywords,
  2. alexaverifyid=$alexaverifyid,
  3. msvalidate=$msvalidate ,google=$google, adminemail=$adminemail, personalemail=$personalemail, titulomensajes=$titulomensajes,
  4. semanal=$semanal,
  5. horario=$horario, telefono=$telefono, tiempo=$tiempo WHERE idconfiguracion='$idconfiguracion'");

 y aparece se muestra esto
Código
  1. UPDATE maca_configuracion SET
  2.    tituloweb=Nombre Web,
  3.    descripcionweb=Descripcion Web,
  4.    keywords=Keywords,
  5.    alexaverifyid=Alexa ID,
  6.    msvalidate=Microsoft Id,
  7.    google=Google ID,
  8.    adminemail=Admin Email,
  9.    personalemail=Personale Email,
  10.    titulomensajes=Titulos Asunto,
  11.    semanal=Trabajo de,
  12.    horario=Horario de,
  13.    telefono=Tel&#233;fono,
  14.    tiempo=0
  15. WHERE idconfiguracion='0'

Pero en cuanto pongo esto
Código
  1. $result =mysql_query("UPDATE maca_configuracion SET tituloweb=$tituloweb, descripcionweb=$descripcionweb, keywords=$keywords,
  2. alexaverifyid=$alexaverifyid,
  3. msvalidate=$msvalidate ,google=$google, adminemail=$adminemail, personalemail=$personalemail, titulomensajes=$titulomensajes,
  4. semanal=$semanal,
  5. horario=$horario, telefono=$telefono, tiempo=$tiempo WHERE idconfiguracion='$idconfiguracion'") or die(mysql_error());

me tira el error.
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 'Web, descripcionweb=Descripcion Web, keywords=Keywords, alexaverifyid=Alexa ID,' at line 1

sobre lo del filtrado lo quite momentáneamente por que ya no se de donde podría proceder el error.

Un saludo y gracias de nuevo
« Última modificación: 15 Febrero 2012, 08:43 am por DeXon18 » En línea

cassiani


Desconectado Desconectado

Mensajes: 978


« Anterior | Próximo »


Ver Perfil WWW
Re: Update con php
« Respuesta #3 en: 16 Febrero 2012, 00:02 am »

tus campos son varchar, coloca los valores entre comillas simples:

Código
  1. $result =mysql_query("UPDATE maca_configuracion SET tituloweb='$tituloweb', descripcionweb='$descripcionweb', keywords='$keywords',
  2. alexaverifyid='$alexaverifyid',
  3. msvalidate='$msvalidate' ,google='$google', adminemail='$adminemail', personalemail='$personalemail', titulomensajes='$titulomensajes',
  4. semanal='$semanal',
  5. horario='$horario', telefono='$telefono', tiempo='$tiempo' WHERE idconfiguracion=$idconfiguracion") or die(mysql_error());
En línea

DeXon18

Desconectado Desconectado

Mensajes: 25


Ver Perfil
Re: Update con php
« Respuesta #4 en: 16 Febrero 2012, 08:12 am »

Ahora si gracias por la solucion!
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Insertar datos con un update, dentro de otro update con SQLi(Mysql)
Nivel Web
WarGhost 3 5,625 Último mensaje 23 Agosto 2011, 03:37 am
por WarGhost
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines