Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General » Mysql »

Problemas con la carga de Regisros en Base de Datos

Estas en el tema de Problemas con la carga de Regisros en Base de Datos en el foro de Mysql en Foros del Web. hola hola, tengo un drama feo con una carga de base de datos, al parecer esta bien pero "supuestamente" me carga el registro nada mas ...
  #1 (permalink)  
Antiguo 25/10/2008, 09:57
Avatar de hackteam  
Fecha de Ingreso: diciembre-2007
Mensajes: 67
Antigüedad: 16 años, 4 meses
Puntos: 0
Problemas con la carga de Regisros en Base de Datos

hola hola, tengo un drama feo con una carga de base de datos, al parecer esta bien pero "supuestamente" me carga el registro nada mas que no veo nada en mi base de datos y siempre genera el id=0
este es el codigo:

Código PHP:

<?php include 'header.php'?>
<?php
if (loggedin())
{
        
$title mysql_escape_string(stripslashes($_POST['title']));
        
$hname mysql_escape_string(stripslashes($_POST['hname']));
        
$type mysql_escape_string(stripslashes($_POST['type']));
        
$code mysql_escape_string(stripslashes($_POST['code']));
        
$description mysql_escape_string(stripslashes(nl2br($_POST['description'])));
        
$instructions mysql_escape_string(stripslashes(nl2br($_POST['instructions'])));
        
$credits mysql_escape_string(stripslashes(nl2br($_POST['credits'])));
        
$width mysql_escape_string(intval(stripslashes($_POST['width'])));
        
$height mysql_escape_string(intval(stripslashes($_POST['height'])));
        
$codetype mysql_escape_string(stripslashes($_POST['codetype']));
        
$reverse mysql_escape_string(stripslashes($_POST['reverse']));
        if (
$reverse == 'on')
        {
                
$reverse_scoring '1';
        }
        else
        {
                
$reverse_scoring '0';
        }
        
$err "";
        
connect();
        
$query "SELECT * FROM gtypes";
        
$result mysql_query($query);
        
$okg 0;
        while (
$row mysql_fetch_array($result))
        {
                if (
$row['type'] === $type)
                {
                        
$okg++;
                }
        }
        if (
$okg == 0)
        {
                
$err .= "<li>Invalid game type</li>\n";
        }
        
$query "SELECT * FROM games";
        
$result mysql_query($query);
        
$okt 0;
        while (
$row mysql_fetch_array($result))
        {
                if (
$row['name'] === stripslashes($title))
                {
                        
$okt++;
                }
        }
        if (
$okt != 0)
        {
                
$err .= "<li>Game title already used</li>\n";
        }
        if (
$title == "")
        {
                
$err .= "<li>Must enter a title</li>\n";
        }
        
//if($code==""){
        //$err.="<li>Must have code for the game</li>\n";
        //}
        
if ($width == "0")
        {
                
$err .= "<li>Must enter a width</li>\n";
        }
        if (
$height == "0")
        {
                
$err .= "<li>Must enter a height</li>\n";
        }
        if (
$codetype == "")
        {
                
$err .= "<li>Must enter a code type (flash, java, etc.)</li>\n";
        }
        if (
$description == "")
        {
                
$err .= "<li>Must provide a game description</li>\n";
        }
        if (
$instructions == "")
        {
                
$err .= "<li>Must provide game instructions</li>\n";
        }
        if (
$credits == "")
        {
                
$err .= "<li>Must provide game credits</li>\n";
        }
        if (
$_FILES['small']['name'] == "")
        {
                
$err .= "<li>Must choose a small thumbnail image</li>\n";
        }
        if (
$_FILES['large']['name'] == "")
        {
                
$err .= "<li>Must choose a large thumbnail image</li>\n";
        }
        if (
$_FILES['game1']['name'] == "")
        {
                
$err .= "<li>Must choose a Shockware, Flash, or Java file</li>\n";
        }
        if (
$err != "")
        {
                
message("The following must be fixed:<br>\n<ul>\n$err</ul>");
        }
        else
        {
                
// Prepare to Upload Small Thumb
                
$sext1 explode("."$_FILES['small']['name']);
                
$s1 count($sext1);
                
$sext $sext1[$s1 1];
                
$sname stripuser($title) . "_small.$sext";
                
$dir_path getcwd() . "/games/";
                
$tmp_path $_FILES['small']['tmp_name'];
                
$target_path $dir_path $sname;
                if (!
move_uploaded_file($tmp_path$target_path))
                {
                        if (!
copy($tmp_path$target_path))
                        {
                                
message('Couldn\'t move the uploaded Small thumbnail. ' E_USER_WARNING);
                        }
                }
                while (
file_exists($tmp_path))
                {
                        
unlink($tmp_path);
                        
clearstatcache();
                }
                
// Prepare to Upload Large Thumb
                
$lext1 explode("."$_FILES['large']['name']);
                
$l1 count($lext1);
                
$lext $lext1[$l1 1];
                
$lname stripuser($title) . "_large.$lext";
                
$tmp_path $_FILES['large']['tmp_name'];
                
$target_path $dir_path $lname;
                if (!
move_uploaded_file($tmp_path$target_path))
                {
                        if (!
copy($tmp_path$target_path))
                        {
                                
message('Couldn\'t move the uploaded Large thumbnail. ' E_USER_WARNING);
                        }
                }
                while (
file_exists($tmp_path))
                {
                        
unlink($tmp_path);
                        
clearstatcache();
                }
                
// Prepare to Upload Game File
                
$gext1 explode("."$_FILES['game1']['name']);
                
$g1 count($gext1);
                
$gext $gext1[$g1 1];
                
$gname stripuser($title) . ".$gext";
                
$tmp_path $_FILES['game1']['tmp_name'];
                
$target_path $dir_path $gname;
                if (!
move_uploaded_file($tmp_path$target_path))
                {
                        if (!
copy($tmp_path$target_path))
                        {
                                
message('Couldn\'t move the uploaded file. ' E_USER_WARNING);
                        }
                }
                while (
file_exists($tmp_path))
                {
                        
unlink($tmp_path);
                        
clearstatcache();
                }
                
$memberID $_COOKIE['id'];
                
$query "INSERT INTO games VALUES ('','$title','0','$code','$type','$description','$instructions','$credits','games/$sname','games/$lname','games/$gname','$hname','$width','$height','$codetype', '$reverse_scoring', '0', '$memberID')";
                
$result mysql_query($query);
                
$in_id mysql_insert_id();
                
message("<a href=\"game.php?id={$in_id}\">" stripslashes($title) . "</a> successfully added.");
        }
        
mysql_close();
}
else
{
        
message("You must be logged in to use this feature.");
}
?>
<?php 
require_once 'footer.php'?>
Esta es la base de datos

Código:
--
-- Estructura de tabla para la tabla `games`
--

CREATE TABLE IF NOT EXISTS `games` (
  `gameid` bigint(20) unsigned NOT NULL auto_increment,
  `name` text NOT NULL,
  `plays` bigint(20) unsigned NOT NULL default '0',
  `code` text NOT NULL,
  `type` text NOT NULL,
  `description` text NOT NULL,
  `instructions` text NOT NULL,
  `credits` text NOT NULL,
  `sthumb` text NOT NULL,
  `lthumb` text NOT NULL,
  `file1` text NOT NULL,
  `hname` text NOT NULL,
  `width` int(10) unsigned NOT NULL default '550',
  `height` int(10) unsigned NOT NULL default '400',
  `codetype` text NOT NULL,
  `reverse_scoring` tinyint(1) NOT NULL default '0',
  `display` tinyint(1) NOT NULL default '1',
  PRIMARY KEY  (`gameid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1639 ;

--
-- Volcar la base de datos para la tabla `games`
--

INSERT INTO `games` (`gameid`, `name`, `plays`, `code`, `type`, `description`, `instructions`, `credits`, `sthumb`, `lthumb`, `file1`, `hname`, `width`, `height`, `codetype`, `reverse_scoring`, `display`) VALUES
(1638, 'test test', 0, '', 'Puzzle', 'testtttttt', 'testtttttt', 'testtttttt', 'games/testtest_small.png', 'games/testtest_large.png', 'games/testtest.swf', '100000', 500, 400, 'Flash', 0, 0),
(13, 'test 13', 12, 'Puzzle', 'bla bla bla', 'bla bla bla', 'bla bla bla', 'games/13diasenelinfierno_small.gif', 'games/13diasenelinfierno_large.gif', '', 'games/13diasenelinfierno.swf', '640', 480, 0, '0', 0, 1),
(1637, 'title', 0, 'code', 'type', 'description', 'instructions', 'redits', 'games/$sname', 'games/lname', 'games/gname', 'hname', 0, 0, 'codetype', 0, 0);
esos son los registros que agregue tocando la linea 162

Linea: 162 que creo es la que da problemas

$query = "INSERT INTO games VALUES ('','$title','0','$code','$type','$description','$ instructions','$credits','games/$sname','games/$lname','games/$gname','$hname','$width','$height','$codetype', '$reverse_scoring', '0', '$memberID')";

por favor una ayuda, gracias!
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 06:40.