Foros del Web » Programando para Internet » PHP »

[SOLUCIONADO] Error con insert

Estas en el tema de Error con insert en el foro de PHP en Foros del Web. Buenas hace un tiempo publique para que me ayudaran pero me dieron tremendas vueltas que con la seguirdad y que no se que y al ...
  #1 (permalink)  
Antiguo 14/09/2016, 13:51
 
Fecha de Ingreso: julio-2014
Ubicación: Montevideo
Mensajes: 78
Antigüedad: 9 años, 9 meses
Puntos: 2
Error con insert

Buenas hace un tiempo publique para que me ayudaran pero me dieron tremendas vueltas que con la seguirdad y que no se que y al final no me ayudaron para nada en mi problema, esta vez para que puedan ayudarme mejor hice un codigo simple y tampoco funciona, yo creo que es un problema con la tabla pero en verdad me esta volviendo loco.

Resulta que en toda la pagina uso la misma forma de insertar, peero al cambiar de hosting el registro y solo el registro dejo de insertar, directamente el query no se ejecuta, la pregunta es. ¿Porque? si yo este mismo codigo lo pongo para que guarde en otra tabla que no sea "cuenta", guarda sin ningun problema, peero cuando le pongo a esta tabla ocurre esto. Alguien me podria ayudar? Les dejo tambien la estructura de la tabla.

registro.php

Código PHP:
<?php
include("conexion.php");


$nombre $_POST["nombre"];
$email $_POST["email"];
$pass $_POST["password"];

 
$sql "insert into cuenta(nombre,email,pass) value ('$nombre', '$email', '$pass')"
 
            
$query $con->query($sql); 
            
            
            if(
$query!=null){echo "Todo bien";}else{echo "Algo salio mal";}
            
            
            
?>
conexion.php

Código PHP:
<?php
$host
="localhost";
$user="****";
$password="*****";
$db="*****";
$con = new mysqli($host,$user,$password,$db);

?>
tabla MYSQL

Código:
-- phpMyAdmin SQL Dump
-- version 4.0.10.14
-- http://www.phpmyadmin.net
--
-- Servidor: localhost:3306
-- Tiempo de generación: 14-09-2016 a las 13:55:28
-- Versión del servidor: 5.6.30-cll-lve
-- Versión de PHP: 5.6.20

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Base de datos: `samp_roleplay`
--

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

--
-- 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` int(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,
  `moneda` int(60) NOT NULL,
  `encasa` int(60) NOT NULL,
  `enropero` int(60) NOT NULL,
  `engarage` int(60) NOT NULL,
  `hprecio` int(60) NOT NULL,
  `hmoneda` int(60) NOT NULL,
  `h2precio` int(60) NOT NULL,
  `h2moneda` int(60) NOT NULL,
  `casaid` int(60) NOT NULL,
  `casaid2` int(50) NOT NULL,
  `hx` float NOT NULL,
  `hy` float NOT NULL,
  `hz` float NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=17 ;

--
-- Volcado de datos para la tabla `cuenta`
--

INSERT INTO `cuenta` (`id`, `nombre`, `pass`, `email`, `ems`, `posx`, `posy`, `posz`, `angle`, `sexo`, `edad`, `skin`, `vida`, `chaleco`, `adminlvl`, `interiorid`, `virtualworldid`, `pwp0`, `pwp1`, `pwp2`, `pwp3`, `pwp4`, `pwp5`, `pwp6`, `pwp7`, `pwp8`, `pwp9`, `pwp10`, `pwp11`, `pwp12`, `Agonizando`, `miembro`, `rango`, `cargos`, `pmodelo`, `placa`, `duty`, `job`, `vipjob`, `dinero`, `dinerobank`, `banco`, `movil`, `dni`, `carcel`, `jailminutes`, `dudechannel`, `keycar1`, `keycar2`, `keycar3`, `pizza`, `hamburgesa`, `helado`, `bebida`, `jbarreta`, `jdestornillador`, `jmartillo`, `pnivelladron`, `pexpladron`, `piezas`, `pnivelarmero`, `pexparmero`, `pmedicamentos`, `pcrack`, `pmateriales`, `pnivelCamionero`, `pexpcamionero`, `bankt`, `vip`, `banka`, `nivel`, `arrestado`, `ptiempocarcelm`, `ptiempocarcels`, `ptiempojail`, `ptiempojails`, `pmaskuse`, `ve1`, `ve2`, `ve3`, `ve4`, `vkey`, `vd`, `vmodelid`, `vposx`, `vposy`, `vposz`, `vangle`, `vcolor1`, `vcolor2`, `vpaintjob`, `vm1`, `vm2`, `vm3`, `vm4`, `vm5`, `vm6`, `vm7`, `vm8`, `vm9`, `vm10`, `vm11`, `vm12`, `vm13`, `vm14`, `vm15`, `vm16`, `vm17`, `vm`, `vvida`, `vpanels`, `vdoors`, `vluces`, `vruedas`, `moneda`, `encasa`, `enropero`, `engarage`, `hprecio`, `hmoneda`, `h2precio`, `h2moneda`, `casaid`, `casaid2`, `hx`, `hy`, `hz`) VALUES
(14, 'Juan_caa', 'mati', '[email protected]', 1, 220.055816, 1244.252319, 1082.140625, 184.788284, 0, 21, 59, 100, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 990, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 0, '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 0, 10, 0, 0, 0, 8, 0, 0, 0, 0),
(15, 'Matias_Capotte', 'mati', '[email protected]', 1, 1515.37622, -1736.693481, 13.382812, 249.198135, 0, 21, 0, 100, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 0, 0, 0, 0, 0, 0, 990, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 0, '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 0),
(16, 'Matias_Capott', 'mati', 'awd,@.co', 1, 1518.072143, -1741.373413, 13.546875, 345.94165, 0, 21, 0, 100, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 995, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 0, '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
__________________
¿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 14/09/2016, 15:34
 
Fecha de Ingreso: enero-2013
Ubicación: Santa Fe, VT
Mensajes: 68
Antigüedad: 11 años, 2 meses
Puntos: 2
Respuesta: Error con insert

creo que seria productivo ver el ultimo error que lanza la base de datos
Código PHP:
Ver original
  1. <?php
  2. include("conexion.php");
  3.  
  4.  
  5. $nombre = $_POST["nombre"];
  6. $email = $_POST["email"];
  7. $pass = $_POST["password"];
  8.  
  9.  $sql = $con->escape_string("insert into cuenta(nombre,email,pass) value ('$nombre', '$email', '$pass')");  
  10.  
  11.             $query = $con->query($sql);
  12.             echo $con->error;
  13.             //if($query!=null){echo "Todo bien";}else{echo "Algo salio mal";}
  14.  
  15.  
  16.             ?>
  #3 (permalink)  
Antiguo 14/09/2016, 16:05
 
Fecha de Ingreso: enero-2015
Ubicación: Cordoba, Andalucía
Mensajes: 111
Antigüedad: 9 años, 3 meses
Puntos: 15
Respuesta: Error con insert

Debe ser la version mysql que tienes, creo que ahora no te deja insertar registros con campos NOT NULL vacios
  #4 (permalink)  
Antiguo 14/09/2016, 19:31
 
Fecha de Ingreso: agosto-2012
Ubicación: M.
Mensajes: 2.031
Antigüedad: 11 años, 8 meses
Puntos: 52
Respuesta: Error con insert

pues a lo que veo a simple vista es que no te permite campos nulos y a fuerzas debes enviarle algo.
intenta quitarles el not null.
__________________
a veces creemos que es algo básico pero al profundizar nos damos cuenta que estábamos tocando solo la cola de la culebra
  #5 (permalink)  
Antiguo 15/09/2016, 09:14
 
Fecha de Ingreso: julio-2014
Ubicación: Montevideo
Mensajes: 78
Antigüedad: 9 años, 9 meses
Puntos: 2
Respuesta: Error con insert

Cita:
Iniciado por molinasergio91 Ver Mensaje
creo que seria productivo ver el ultimo error que lanza la base de datos
Código PHP:
Ver original
  1. <?php
  2. include("conexion.php");
  3.  
  4.  
  5. $nombre = $_POST["nombre"];
  6. $email = $_POST["email"];
  7. $pass = $_POST["password"];
  8.  
  9.  $sql = $con->escape_string("insert into cuenta(nombre,email,pass) value ('$nombre', '$email', '$pass')");  
  10.  
  11.             $query = $con->query($sql);
  12.             echo $con->error;
  13.             //if($query!=null){echo "Todo bien";}else{echo "Algo salio mal";}
  14.  
  15.  
  16.             ?>
Muchas gracias por sus respuestas, definitivamente era el problema que decia el colega de abajo, y ver el error me ayudo a darme cuenta. Al parecer mi proveedor de hosting actualizo su version de mysql y la version nueva no permite dejar campos sin un default. Muchas gracias y espero que a alguien mas le sirva.
__________________
¿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: insert, mysql, 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 13:45.