asked on
$corte=substr($_POST['idmed'] ,-4, strlen($_POST['idmed'] )-0);
$fechareg = date("Y-m-d h:i:s");
if($con->conectar()==true){
if ($_POST['chkm']=="true"){
if($_POST['chken']=="true"){//January
$query_Insert= "INSERT INTO cit_distribucion (codigo,iddistribucionmed,idtipocon,idrangohoras,idempleado,primera,subsecuente,mes,yrs,dia,IdUsuarioReg,FechaHoraReg) VALUES ('0',concat('L','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',1,'".$_POST['txtyr']."',2,'0','$fechareg')";
$query = @mysql_query($query_Insert) or die('La consulta falloó: ' . @mysql_error());
}
if($_POST['chkfb']=="true"){//February
$query_Insert= "INSERT INTO cit_distribucion (codigo,iddistribucionmed,idtipocon,idrangohoras,idempleado,primera,subsecuente,mes,yrs,dia,IdUsuarioReg,FechaHoraReg) VALUES ('0',concat('L','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',2,'".$_POST['txtyr']."',2,'0','$fechareg')";
$query = @mysql_query($query_Insert) or die('La consulta falloó: ' . @mysql_error());
}
if($_POST['chkmz']=="true"){//March
$query_Insert= "INSERT INTO cit_distribucion (codigo,iddistribucionmed,idtipocon,idrangohoras,idempleado,primera,subsecuente,mes,yrs,dia,IdUsuarioReg,FechaHoraReg) VALUES ('0',concat('L','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',3,'".$_POST['txtyr']."',2,'0','$fechareg')";
$query = @mysql_query($query_Insert) or die('La consulta falloó: ' . @mysql_error());
}
}//End of the if for Monday
if ($_POST['chkt']=="true"){//Ini for Tuesday
if($_POST['chken']=="true"){//January
$query_Insert= "INSERT INTO cit_distribucion (codigo,iddistribucionmed,idtipocon,idrangohoras,idempleado,primera,subsecuente,mes,yrs,dia,IdUsuarioReg,FechaHoraReg) VALUES ('0',concat('M','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',1,'".$_POST['txtyr']."',3,'0','$fechareg')";
$query = @mysql_query($query_Insert) or die('La consulta falloó: ' . @mysql_error());
}
if($_POST['chkfb']=="true"){//February
$query_Insert= "INSERT INTO cit_distribucion (codigo,iddistribucionmed,idtipocon,idrangohoras,idempleado,primera,subsecuente,mes,yrs,dia,IdUsuarioReg,FechaHoraReg) VALUES ('0',concat('M','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',2,'".$_POST['txtyr']."',3,'0','$fechareg')";
$query = @mysql_query($query_Insert) or die('La consulta falloó: ' . @mysql_error());
}
if($_POST['chkmz']=="true"){//March
$query_Insert= "INSERT INTO cit_distribucion (codigo,iddistribucionmed,idtipocon,idrangohoras,idempleado,primera,subsecuente,mes,yrs,dia,IdUsuarioReg,FechaHoraReg) VALUES ('0',concat('M','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',3,'".$_POST['txtyr']."',3,'0','$fechareg')";
$query = @mysql_query($query_Insert) or die('La consulta falloó: ' . @mysql_error());
}
}
<?
foreach($HTTP_POST_VARS as $key => $value){
echo "$key = $value <BR>";
}
?>
ASKER
$corte=substr($_POST['idmed'] ,-4, strlen($_POST['idmed'] )-0);
$fechareg = date("Y-m-d h:i:s");
$months = array($_POST['chkjanuary'],$_POST['chkfebruary'],$_POST['chkmarch'],$_POST['chkapril'],$_POST['chkmay'],$_POST['chkjune'],$_POST['chkjuly'],$_POST['chkagoust'],$_POST['chkseptember'],$_POST['chkoctober'],$_POST['chknovember'],$_POST['chkdecember'],$_POST['chkall']);
$tamano=sizeof($months);
if($con->conexion()==true){
for ($i=0;$i<$tamano;$i++){
if($months[$i]=="true"){
if($_POST['chkmonday']=="true"){
$query_Insert= "INSERT INTO cit_distribution (Id,Iddistribuciotion,IdType,IdTime,IdEmployee,First,Second,Month,Year,Day,IdUserReg,DateTimeReg) VALUES ('0',concat('L','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',$i,'".$_POST['txtyr']."',2,'0','$fechareg')";
$query = mysql_query($query_Insert) or die('Query Trouble' . @mysql_error());
}
if($_POST['chktuesday']=="true"){
$query_Insert= "INSERT INTO cit_distribution (Id,Iddistribuciotion,IdType,IdTime,IdEmployee,First,Second,Month,Year,Day,IdUserReg,DateTimeReg) VALUES ('0',concat('L','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',$i,'".$_POST['txtyr']."',3,'0','$fechareg')";
$query = mysql_query($query_Insert) or die('Query Trouble' . @mysql_error());
}
if($_POST['chkwednesday']=="true"){
$query_Insert= "INSERT INTO cit_distribution (Id,Iddistribuciotion,IdType,IdTime,IdEmployee,First,Second,Month,Year,Day,IdUserReg,DateTimeReg) VALUES ('0',concat('L','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',$i,'".$_POST['txtyr']."',4,'0','$fechareg')";
$query = mysql_query($query_Insert) or die('Query Trouble' . @mysql_error());
}
if($_POST['chkthusday']=="true"){
$query_Insert= "INSERT INTO cit_distribution (Id,Iddistribuciotion,IdType,IdTime,IdEmployee,First,Second,Month,Year,Day,IdUserReg,DateTimeReg) VALUES ('0',concat('L','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',$i,'".$_POST['txtyr']."',5,'0','$fechareg')";
$query = mysql_query($query_Insert) or die('Query Trouble' . @mysql_error());
}
if($_POST['chkfriday']=="true"){
$query_Insert= "INSERT INTO cit_distribution (Id,Iddistribuciotion,IdType,IdTime,IdEmployee,First,Second,Month,Year,Day,IdUserReg,DateTimeReg) VALUES ('0',concat('L','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',$i,'".$_POST['txtyr']."',6,'0','$fechareg')";
$query = mysql_query($query_Insert) or die('Query Trouble' . @mysql_error());
}
}
}
}
$corte=substr($_POST['idmed'] ,-4, strlen($_POST['idmed'] )-0);
$fechareg = date("Y-m-d h:i:s");
$months = array('chkjanuary','chkfebruary','chkmarch','chkapril','chkmay','chkjune','chkjuly','chkagoust','chkseptember','chkoctober','chknovember','chkdecember','chkall');
$tamano=sizeof($months);
if($con->conexion()==true){
for ($i=0;$i<$tamano;$i++){
if( isset($_POST[$months[$i]]) ){
if($_POST['chkmonday']){
$query_Insert= "INSERT INTO cit_distribution (Id,Iddistribuciotion,IdType,IdTime,IdEmployee,First,Second,Month,Year,Day,IdUserReg,DateTimeReg) VALUES (NULL,concat('L','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',$i,'".$_POST['txtyr']."',2,'0','$fechareg')";
$query = mysql_query($query_Insert) or die('Query Trouble' . @mysql_error());
}
if($_POST['chktuesday']){
$query_Insert= "INSERT INTO cit_distribution (Id,Iddistribuciotion,IdType,IdTime,IdEmployee,First,Second,Month,Year,Day,IdUserReg,DateTimeReg) VALUES (NULL,concat('L','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',$i,'".$_POST['txtyr']."',3,'0','$fechareg')";
$query = mysql_query($query_Insert) or die('Query Trouble' . @mysql_error());
}
if($_POST['chkwednesday']){
$query_Insert= "INSERT INTO cit_distribution (Id,Iddistribuciotion,IdType,IdTime,IdEmployee,First,Second,Month,Year,Day,IdUserReg,DateTimeReg) VALUES (NULL,concat('L','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',$i,'".$_POST['txtyr']."',4,'0','$fechareg')";
$query = mysql_query($query_Insert) or die('Query Trouble' . @mysql_error());
}
if($_POST['chkthusday']){
$query_Insert= "INSERT INTO cit_distribution (Id,Iddistribuciotion,IdType,IdTime,IdEmployee,First,Second,Month,Year,Day,IdUserReg,DateTimeReg) VALUES (NULL,concat('L','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',$i,'".$_POST['txtyr']."',5,'0','$fechareg')";
$query = mysql_query($query_Insert) or die('Query Trouble' . @mysql_error());
}
if($_POST['chkfriday']){
$query_Insert= "INSERT INTO cit_distribution (Id,Iddistribuciotion,IdType,IdTime,IdEmployee,First,Second,Month,Year,Day,IdUserReg,DateTimeReg) VALUES (NULL,concat('L','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',$i,'".$_POST['txtyr']."',6,'0','$fechareg')";
$query = mysql_query($query_Insert) or die('Query Trouble' . @mysql_error());
}
}
}
}
ASKER
ASKER
$corte=substr($_POST['idmed'] ,-4, strlen($_POST['idmed'] )-0);
$fechareg = date("Y-m-d h:i:s");
$months = array($_POST['chkjanuary'],$_POST['chkfebruary'],$_POST['chkmarch'],$_POST['chkapril'],$_POST['chkmay'],$_POST['chkjune'],$_POST['chkjuly'],$_POST['chkagoust'],$_POST['chkseptember'],$_POST['chkoctober'],$_POST['chknovember'],$_POST['chkdecember'],$_POST['chkall']);
$tamano=sizeof($months);
if($con->conexion()==true){
for ($i=0;$i<$tamano;$i++){
if($months[$i]=="true"){
if($_POST['chkmonday']=="true"){
$query_Insert= "INSERT INTO cit_distribution (Id,Iddistribuciotion,IdType,IdTime,IdEmployee,First,Second,Month,Year,Day,IdUserReg,DateTimeReg) VALUES (NULL,concat('L','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',$i,'".$_POST['txtyr']."',2,'0','$fechareg')";
echo('Mon: '.$query_Insert);
$query = mysql_query($query_Insert) or die('Query Trouble' . mysql_error());
}
if($_POST['chktuesday']=="true"){
$query_Insert= "INSERT INTO cit_distribution (Id,Iddistribuciotion,IdType,IdTime,IdEmployee,First,Second,Month,Year,Day,IdUserReg,DateTimeReg) VALUES (NULL,concat('L','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',$i,'".$_POST['txtyr']."',3,'0','$fechareg')";
echo('Tue: '.$query_Insert);
$query = mysql_query($query_Insert) or die('Query Trouble' . mysql_error());
}
if($_POST['chkwednesday']=="true"){
$query_Insert= "INSERT INTO cit_distribution (Id,Iddistribuciotion,IdType,IdTime,IdEmployee,First,Second,Month,Year,Day,IdUserReg,DateTimeReg) VALUES (NULL,concat('L','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',$i,'".$_POST['txtyr']."',4,'0','$fechareg')";
echo('Wed: '.$query_Insert);
$query = mysql_query($query_Insert) or die('Query Trouble' . mysql_error());
}
if($_POST['chkthusday']=="true"){
$query_Insert= "INSERT INTO cit_distribution (Id,Iddistribuciotion,IdType,IdTime,IdEmployee,First,Second,Month,Year,Day,IdUserReg,DateTimeReg) VALUES (NULL,concat('L','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',$i,'".$_POST['txtyr']."',5,'0','$fechareg')";
echo('Thu: '.$query_Insert);
$query = mysql_query($query_Insert) or die('Query Trouble' . mysql_error());
}
if($_POST['chkfriday']=="true"){
$query_Insert= "INSERT INTO cit_distribution (Id,Iddistribuciotion,IdType,IdTime,IdEmployee,First,Second,Month,Year,Day,IdUserReg,DateTimeReg) VALUES (NULL,concat('L','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',$i,'".$_POST['txtyr']."',6,'0','$fechareg')";
echo('Fri: '.$query_Insert);
$query = mysql_query($query_Insert) or die('Query Trouble' . mysql_error());
}
}
}
}
PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.
TRUSTED BY
If you have a faulty insertion you won't be able to se that with your current settings.
Second, the code doesn't make much sense to me, probably because I don't know the language you have named your variables and database fields in. Makes it real hard to read.
So far I can only reccomend you print checkpoints in all if-statements to see that they are entered, and then check the SQL queries.
Regards,
Andreas