Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/04/2011, 12:48
Avatar de destor77
destor77
 
Fecha de Ingreso: noviembre-2004
Ubicación: Gálvez, Santa Fe, Argentina
Mensajes: 2.654
Antigüedad: 19 años, 5 meses
Puntos: 43
error al crear tablas mysql

Hola,
tengo el siguiente método:
Código PHP:
Ver original
  1. public function crearDb() {
  2.         $sql = "
  3.                --
  4.                -- Estructura de tabla para la tabla actualizaciones
  5.                --
  6.  
  7.                CREATE TABLE actualizaciones (
  8.                  id int(11) NOT NULL AUTO_INCREMENT,
  9.                  seccion varchar(255) NOT NULL,
  10.                  actualizacion datetime NOT NULL,
  11.                  PRIMARY KEY (id)
  12.                ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
  13.  
  14.                -- --------------------------------------------------------
  15.  
  16.                --
  17.                -- Estructura de tabla para la tabla core_configuracion
  18.                --
  19.  
  20.                CREATE TABLE core_configuracion (
  21.                  id int(11) NOT NULL,
  22.                  titulo varchar(255) NOT NULL,
  23.                  descripcion text,
  24.                  keywords text,
  25.                  email varchar(255) DEFAULT NULL,
  26.                  user_email varchar(255) DEFAULT NULL,
  27.                  pass_email varchar(255) DEFAULT NULL,
  28.                  host_email varchar(255) DEFAULT NULL,
  29.                  port_email varchar(255) DEFAULT NULL,
  30.                  themes varchar(255) DEFAULT NULL,
  31.                  lenguajes_id int(11) NOT NULL DEFAULT '1',
  32.                  PRIMARY KEY (titulo,lenguajes_id),
  33.                  KEY fk_core_configuracion_core_lenguajes1 (lenguajes_id)
  34.                ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='contiene la configuración del sitio';
  35.  
  36.                -- --------------------------------------------------------
  37.  
  38.                --
  39.                -- Estructura de tabla para la tabla core_errores
  40.                --
  41.  
  42.                CREATE TABLE core_errores (
  43.                  id int(11) NOT NULL AUTO_INCREMENT,
  44.                  fecha datetime DEFAULT NULL,
  45.                  error text,
  46.                  cod_error varchar(80) DEFAULT NULL,
  47.                  linea int(11) DEFAULT NULL,
  48.                  accion varchar(255) DEFAULT NULL,
  49.                  controlador varchar(255) DEFAULT NULL,
  50.                  core_users_id int(11) NOT NULL,
  51.                  PRIMARY KEY (id,core_users_id),
  52.                  KEY fk_core_errores_core_users1 (core_users_id)
  53.                ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='contiene los errores generados' AUTO_INCREMENT=1 ;
  54.  
  55.              
  56.            ";
  57.         $config = Config::singleton();
  58.  
  59.         $conexion= mysql_connect($config->get('dbhost'), $config->get('dbuser'), $config->get('dbpass'), $config->get('dbname'));
  60.     mysql_select_db($config->get('dbname'), $conexion);
  61.         if(!mysql_query($sql)){
  62.             $consulta = mysql_error();
  63.         }
  64.         else{
  65.             $consulta = true;
  66.         }
  67.         mysql_close();
  68.        
  69.  
  70.         return $consulta;
  71.     }

cuando le ejecuto me tira este error:
Cita:
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 'CREATE TABLE core_configuracion (
id int(11) NOT NULL,
' at line 18
lo mas raro es que si yo copio toda la query y le pego en el phpmyadmin, me crea las tablas sin ningun problema. Donde esta el error????
desde ya muchas gracias