When I try to insert a records in the database "socios", it doesn't inserted at all.
Here is the code:
<?php
function Conectar()
{
if (!($Conexion=mysql_connect("localhost")))
{
echo "Error conecting to the database.";
exit();
}
if (!($sql=mysql_select_db("caja",$Conexion)))
{
echo "Error selecting the database.";
exit();
}
return $Conexion;
}
$Conexion=Conectar();
?>
CREATE TABLE trabm (
idcia int(3) NOT NULL default '0',
idplanta int(3) NOT NULL default '0',
idtrab int(6) NOT NULL default '0',
tipotrab int(1) NOT NULL default '0',
nomtrab char(40) NOT NULL default '',
puesto char(40) NOT NULL default '',
depto char(30) NOT NULL default '',
sdodia decimal(6,2) NOT NULL default '0.00',
fecalta date NOT NULL default '0000-00-00',
fecbaja date NOT NULL default '0000-00-00',
edocivil char(10) NOT NULL default '',
rfc char(15) NOT NULL default '',
confirm char(1) NOT NULL default '',
tipomov int(1) NOT NULL default '0',
feultact date NOT NULL default '0000-00-00',
periodo int(2) NOT NULL default '0',
idsubdiv int(2) NOT NULL default '0',
cuentaban char(12) NOT NULL default '',
KEY ip (idcia,idplanta,idtrab,tipomov)
) TYPE=MyISAM COMMENT='Tabla de movimientos de socios';
#
# Dump table `trabm`
#
INSERT INTO trabm VALUES (1, 1, 1, 1, 'Sol Florencio Pacheco Hernandez', 'jefe', 'sistemas', '500.00', '2003-01-15', '0000-00-00', 'casado', 'pahs580923924', 'f', 0, '0000-00-00', 0, 2, '12345678910');
INSERT INTO trabm VALUES (1, 1, 8, 8, '8888888888888', '', '', '0.00', '0000-00-00', '0000-00-00', '', '', 'f', 0, '0000-00-00', 0, 0, '');
CREATE TABLE socios (
gpo_soc int(2) NOT NULL default '0',
cia_soc int(3) NOT NULL default '0',
pta_soc int(2) NOT NULL default '0',
num_soc int(6) NOT NULL default '0',
nom_soc char(40) NOT NULL default '',
rfc_soc char(15) NOT NULL default '',
sdo_soc decimal(8,2) NOT NULL default '0.00',
sta_soc char(1) NOT NULL default '',
fecalta_soc date NOT NULL default '0000-00-00',
fecbaja_soc date NOT NULL default '0000-00-00',
pto_soc char(20) NOT NULL default '',
dep_soc char(15) NOT NULL default '',
ecivil_soc char(8) NOT NULL default '',
depen_soc int(1) NOT NULL default '0',
tipo_soc int(1) NOT NULL default '0',
tcappf_soc decimal(5,2) NOT NULL default '0.00',
tintav_soc decimal(5,2) NOT NULL default '0.00',
tcapav_soc decimal(5,2) NOT NULL default '0.00',
dscto_soc decimal(9,2) NOT NULL default '0.00',
pordsc_soc decimal(5,2) NOT NULL default '0.00',
capintpf_soc char(2) NOT NULL default '',
tpopag_soc int(1) NOT NULL default '0',
nivel_soc int(1) NOT NULL default '0',
num_tar decimal(12,0) NOT NULL default '0',
log_soc char(10) NOT NULL default '',
puen_soc int(4) NOT NULL default '0',
deptos_soc int(4) NOT NULL default '0',
nip_soc char(8) NOT NULL default '',
PRIMARY KEY (gpo_soc,cia_soc,pta_soc,num_soc),
UNIQUE KEY gpo_soc (gpo_soc,cia_soc,pta_soc,num_soc),
KEY gpo_soc_2 (gpo_soc,cia_soc,pta_soc,num_soc)
) TYPE=MyISAM;
<?php
// Load the file Socios
include("includes/conectar.i");
$result=mysql_query("select * from trabm where confirm = 'f' ",$Conexion);
while($row = mysql_fetch_row($result))
{
$cia = $row["idcia"];
$pta = $row["idplanta"];
$trab = $row["idtrab"];
$nomtrab = $row["nomtrab"];
$fecalta = $row["fecalta"];
$fecbaja = $row["fecbaja"];
$sdodia = $row["sdodia"];
$puesto = $row["puesto"];
$depto = $row["depto"];
$edocivil = $row["edocivil"];
$cuentaban = $row["cuentaban"];
$rfc = $row["rfc"];
$idsubdiv = $row["idsubdiv"];
{ $i = 1; }
$login = $trab;
$nip = "1111";
$res=mysql_query("select * from socios where gpo_soc = 1 and cia_soc = '$cia' and pta_soc = '$pta' and num_soc = '$trab'",$Conexion);
$row = mysql_fetch_array($res);
if ($row)
{
$graba=("update socios set nom_soc='$nomtrab',fecalta_soc='$fecalta',fecbaja='$fecbaja',sdo_soc='$sdodia',pto_soc='$puesto',dep
_soc='$depto',ecivil_soc='$edocivil',num_tar='$cuentaban',tipo_soc='$i',rfc_soc='$rfc',login_soc='$l
ogin',nip_soc='$nip'");
mysql_query($graba,$Conexion);
}
else
{
$graba=("insert into 'socios' ('gpo_soc','cia_soc','pta_soc','num_soc','nom_soc','fecalta_soc','fecbaja_soc','sdo_soc','pto_soc','
dep_soc','ecivil_soc','num_tar','tipo_soc','rfc_soc','log_soc','nip_soc') values ('1','$cia','$pta','$trab','$nomtrab','$fecalta','$fecbaja','$sdodia','$puesto','$depto','$edocivil'
,'$cuentaban','$i','$rfc','$login','$nip')");
mysql_query($graba,$Conexion);
}
}
?>
Any idea why cannot insert the record in the database?
Thanks.
Be happy :p