Foros del Web » Programando para Internet » PHP »

Problema con INSERT

Estas en el tema de Problema con INSERT en el foro de PHP en Foros del Web. Buenas gente de forosdelweb, resulta que hace poco cambie mi hosting de Godaddy a otra empresa por motivos económicos, pero ahora estoy volviendo a adquirir ...
  #1 (permalink)  
Antiguo 08/09/2016, 09:03
 
Fecha de Ingreso: julio-2014
Ubicación: Montevideo
Mensajes: 78
Antigüedad: 9 años, 9 meses
Puntos: 2
Problema con INSERT

Buenas gente de forosdelweb, resulta que hace poco cambie mi hosting de Godaddy a otra empresa por motivos económicos, pero ahora estoy volviendo a adquirir un hosting con ellos y el tema que tengo es el siguiente, despues de subir el sitio ajustando cosas al nuevo hosting me di cuenta que el registro no funcionaba, me volvi realmente loco intentando ver cual es el problema y no lo logre, peeero fui borrando algunas lineas a ver si funcionaba y al final por descarte di con el insert que esta dando problemas que es este

Código PHP:
$sql "insert into cuenta(nombre,sexo,email,pass,dinero,dinerobank,nivel,posx,posy,posz,dni) value (\"$_POST[nombre]_$_POST[apellido]\",\"$_POST[genero]\",\"$_POST[email]\",\"$_POST[password]\",750,16000,1,1481.7340,-1743.4836,13.5469,".$cadena.")";
            
$query $con->query($sql); 
Lo raro es que en el hosting anterior funcionaba y en este no, yo de todas formas supongo que es por la base de datos, ya que perdi la base de datos y no la pude importar las fui creando de a poco en el nuevo hosting pero talvez al crearla hay algun valor que puse mal y por eso no guarda, al presionar en crear cuenta queda la clasica pantalla en blanco.

Les dejo el sql de la tabla por si alguien me puede ayudar a darse cuenta del problema.

Código:
-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `cuenta`
--

CREATE TABLE IF NOT EXISTS `cuenta` (
  `id` int(12) NOT NULL AUTO_INCREMENT,
  `nombre` varchar(128) NOT NULL,
  `pass` varchar(128) NOT NULL,
  `email` varchar(128) NOT NULL,
  `ems` int(11) NOT NULL,
  `posx` double NOT NULL,
  `posy` double NOT NULL,
  `posz` double NOT NULL,
  `angle` double NOT NULL,
  `sexo` int(11) NOT NULL,
  `edad` int(11) NOT NULL,
  `skin` int(11) NOT NULL,
  `vida` int(11) NOT NULL,
  `chaleco` int(11) NOT NULL,
  `adminlvl` int(11) NOT NULL,
  `interiorid` int(11) NOT NULL,
  `virtualworldid` int(11) NOT NULL,
  `pwp0` int(11) NOT NULL,
  `pwp1` int(11) NOT NULL,
  `pwp2` int(11) NOT NULL,
  `pwp3` int(11) NOT NULL,
  `pwp4` int(11) NOT NULL,
  `pwp5` int(11) NOT NULL,
  `pwp6` int(11) NOT NULL,
  `pwp7` int(11) NOT NULL,
  `pwp8` int(11) NOT NULL,
  `pwp9` int(11) NOT NULL,
  `pwp10` int(11) NOT NULL,
  `pwp11` int(11) NOT NULL,
  `pwp12` int(11) NOT NULL,
  `Agonizando` int(11) NOT NULL,
  `miembro` int(11) NOT NULL,
  `rango` int(11) NOT NULL,
  `cargos` int(11) NOT NULL,
  `pmodelo` int(11) NOT NULL,
  `placa` int(11) NOT NULL,
  `duty` int(11) NOT NULL,
  `job` int(11) NOT NULL,
  `vipjob` int(11) NOT NULL,
  `dinero` int(50) NOT NULL,
  `dinerobank` int(50) NOT NULL,
  `banco` int(11) NOT NULL,
  `movil` int(20) NOT NULL,
  `dni` varchar(11) NOT NULL,
  `carcel` int(11) NOT NULL,
  `jailminutes` int(11) NOT NULL,
  `dudechannel` int(11) NOT NULL,
  `keycar1` int(11) NOT NULL,
  `keycar2` int(11) NOT NULL,
  `keycar3` int(11) NOT NULL,
  `pizza` int(11) NOT NULL,
  `hamburgesa` int(11) NOT NULL,
  `helado` int(11) NOT NULL,
  `bebida` int(11) NOT NULL,
  `jbarreta` int(11) NOT NULL,
  `jdestornillador` int(50) NOT NULL,
  `jmartillo` int(50) NOT NULL,
  `pnivelladron` int(50) NOT NULL,
  `pexpladron` int(50) NOT NULL,
  `piezas` int(50) NOT NULL,
  `pnivelarmero` int(50) NOT NULL,
  `pexparmero` int(50) NOT NULL,
  `pmedicamentos` int(50) NOT NULL,
  `pcrack` int(50) NOT NULL,
  `pmateriales` int(11) NOT NULL,
  `pnivelCamionero` int(11) NOT NULL,
  `pexpcamionero` int(11) NOT NULL,
  `bankt` int(11) NOT NULL,
  `vip` int(11) NOT NULL,
  `banka` int(11) NOT NULL,
  `nivel` int(11) NOT NULL,
  `arrestado` int(11) NOT NULL,
  `ptiempocarcelm` int(11) NOT NULL,
  `ptiempocarcels` int(11) NOT NULL,
  `ptiempojail` int(11) NOT NULL,
  `ptiempojails` int(11) NOT NULL,
  `pmaskuse` int(11) NOT NULL,
  `ve1` int(11) NOT NULL,
  `ve2` int(11) NOT NULL,
  `ve3` int(11) NOT NULL,
  `ve4` int(11) NOT NULL,
  `vkey` int(50) NOT NULL,
  `vd` varchar(50) NOT NULL,
  `vmodelid` int(11) NOT NULL,
  `vposx` double NOT NULL,
  `vposy` double NOT NULL,
  `vposz` double NOT NULL,
  `vangle` double NOT NULL,
  `vcolor1` int(50) NOT NULL,
  `vcolor2` int(50) NOT NULL,
  `vpaintjob` int(50) NOT NULL,
  `vm1` int(50) NOT NULL,
  `vm2` int(50) NOT NULL,
  `vm3` int(50) NOT NULL,
  `vm4` int(50) NOT NULL,
  `vm5` int(50) NOT NULL,
  `vm6` int(50) NOT NULL,
  `vm7` int(50) NOT NULL,
  `vm8` int(50) NOT NULL,
  `vm9` int(50) NOT NULL,
  `vm10` int(50) NOT NULL,
  `vm11` int(50) NOT NULL,
  `vm12` int(50) NOT NULL,
  `vm13` int(50) NOT NULL,
  `vm14` int(50) NOT NULL,
  `vm15` int(50) NOT NULL,
  `vm16` int(50) NOT NULL,
  `vm17` int(50) NOT NULL,
  `vm` int(50) NOT NULL,
  `vvida` int(50) NOT NULL,
  `vpanels` int(50) NOT NULL,
  `vdoors` int(11) NOT NULL,
  `vluces` int(11) NOT NULL,
  `vruedas` int(11) NOT NULL,
  `fecha_reg` varchar(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ;
__________________
¿Necesitas Hosting Web? - [JSFIDDLE="www.intechservers.com/hosting"]Intech Servers Hosting[/JSFIDDLE]
¿Necesitas Sitio Web? - [JSFIDDLE="www.intechservers.com/web"]Intech Servers Web[/JSFIDDLE]
  #2 (permalink)  
Antiguo 08/09/2016, 09:36
Avatar de jpint  
Fecha de Ingreso: junio-2012
Ubicación: Ciudad Real - España
Mensajes: 97
Antigüedad: 11 años, 10 meses
Puntos: 12
Respuesta: Problema con INSERT

Para empezar, tu consulta no es segura frente ataques de SQL inyection y la sintaxis es horrible.

Pero, a simple vista tienes mal puesto "value" en lugar de "values":


Código PHP:
<?php 

$nombre 
$_POST["nombre"]." ".$_POST["apellido"];
$genero $_POST["genero"];
$email $_POST["email"];
$password $_POST["password"];
$dinero "750";
$dinerobank "16000";
$nivel "1";
$posx ="1481.7340";
$posy "-1743.4836";
$posz "13.5469";
$dni "???";


$sql "insert into cuenta(nombre, sexo, email, pass, dinero, dinerobank, nivel, posx, posy, posz, dni) 
    values ("
.$nombre.", ".$genero.", ".$email.", ".$password.", ".$dinero.", 
        "
.$dinerobank.", ".$nivel.", ".$posx.", ".$posy.", ".$posz.", ".$dni.")"
            
$query $con->query($sql);  

?>
  #3 (permalink)  
Antiguo 08/09/2016, 10:13
 
Fecha de Ingreso: octubre-2010
Ubicación: España
Mensajes: 1.007
Antigüedad: 13 años, 6 meses
Puntos: 123
Respuesta: Problema con INSERT

Como bien dice el compañero, construir una consulta sql de esa forma esta totalmente desaconsejado.

Lectura mínima obligatoria: Inyección de SQL
__________________
Unset($vida['malRollo']);
  #4 (permalink)  
Antiguo 08/09/2016, 11:25
 
Fecha de Ingreso: julio-2014
Ubicación: Montevideo
Mensajes: 78
Antigüedad: 9 años, 9 meses
Puntos: 2
Respuesta: Problema con INSERT

Cita:
Iniciado por jpint Ver Mensaje
Para empezar, tu consulta no es segura frente ataques de SQL inyection y la sintaxis es horrible.

Pero, a simple vista tienes mal puesto "value" en lugar de "values":


Código PHP:
<?php 

$nombre 
$_POST["nombre"]." ".$_POST["apellido"];
$genero $_POST["genero"];
$email $_POST["email"];
$password $_POST["password"];
$dinero "750";
$dinerobank "16000";
$nivel "1";
$posx ="1481.7340";
$posy "-1743.4836";
$posz "13.5469";
$dni "???";


$sql "insert into cuenta(nombre, sexo, email, pass, dinero, dinerobank, nivel, posx, posy, posz, dni) 
    values ("
.$nombre.", ".$genero.", ".$email.", ".$password.", ".$dinero.", 
        "
.$dinerobank.", ".$nivel.", ".$posx.", ".$posy.", ".$posz.", ".$dni.")"
            
$query $con->query($sql);  

?>
Intente como me indicaste pero sigo teniendo el mismo problema.
__________________
¿Necesitas Hosting Web? - [JSFIDDLE="www.intechservers.com/hosting"]Intech Servers Hosting[/JSFIDDLE]
¿Necesitas Sitio Web? - [JSFIDDLE="www.intechservers.com/web"]Intech Servers Web[/JSFIDDLE]
  #5 (permalink)  
Antiguo 09/09/2016, 15:11
 
Fecha de Ingreso: octubre-2010
Ubicación: España
Mensajes: 1.007
Antigüedad: 13 años, 6 meses
Puntos: 123
Respuesta: Problema con INSERT

Y cual es el error que te da?
__________________
Unset($vida['malRollo']);
  #6 (permalink)  
Antiguo 14/09/2016, 13:03
 
Fecha de Ingreso: julio-2014
Ubicación: Montevideo
Mensajes: 78
Antigüedad: 9 años, 9 meses
Puntos: 2
Respuesta: Problema con INSERT

No da error, que da la pagina en blanco
__________________
¿Necesitas Hosting Web? - [JSFIDDLE="www.intechservers.com/hosting"]Intech Servers Hosting[/JSFIDDLE]
¿Necesitas Sitio Web? - [JSFIDDLE="www.intechservers.com/web"]Intech Servers Web[/JSFIDDLE]

Etiquetas: fecha, insert, registro, sql, tabla
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 17:08.