Llevo días y días dando vueltas al mismo código pero no veo nada... Php no me muestra ningún error pero no sube los datos a la BD. Tampoco llega al final donde debería aparecer "datos subidos" o "ha habido un problema al subirlos".
Alguien puede hecharle un ojo porfa??
Código PHP:
include ('connexio.php');
//print_r($_POST);
$nom = $_POST['pl_nm']; //pl_nm a bd
$nom2= $_POST['pl_nm2']; // pl_nm2
$pl_desc = $_POST['pl_desc']; //pl_desc
$pl_hist = $_POST['pl_hist']; //pl_hist
$ac_com = $_POST['ac_com']; //ac_com
$ac_desc = $_POST['ac_desc']; //ac_com
$q = $_POST['q']; //q_id
$countq = count($q);
for ($i = 1; $i < $countq; $i++) {
// echo $q[$i];
}
$sv = $_POST['sv']; //sv_id
$countsv = count($sv);
for ($o = 1; $o < $countsv; $o++) {
// echo $sv[$o];
}
$sr = $_POST['sr']; //sr_id
$fn = $_POST['fn']; //fn_id
$en = $_POST['en']; //en_id
$dif = $_POST['dif']; //dif_id
$img1 = $_POST['img1']; //pl_img1
if ($img1=''){
$img1_nom= $_FILES["img1"]["name"];
$img1_pes= $_FILES["img1"]["size"];
$img1_temp= $_FILES["img1"]["tmp_name"];
}else{
exit;}
$img2= $_POST['img2']; //pl_img2
if ($img2==''){
$img2_nom= $_FILES["img2"]["name"];
$img2_pes= $_FILES["img2"]["size"];
$img2_temp= $_FILES["img2"]["tmp_name"];
}else{
exit;}
$img3 = $_POST['img3']; //pl_img3
if ($img3==''){
$img3_nom= $_FILES["img3"]["name"];
$img3_pes= $_FILES["img3"]["size"];
$img3_temp= $_FILES["img3"]["tmp_name"];
}else{
exit;}
$img4 = $_POST['img4']; //pl_img4
if ($img4==''){
$img4_nom= $_FILES["img4"]["name"];
$img4_pes= $_FILES["img4"]["size"];
$img4_temp= $_FILES["img4"]["tmp_name"];
}else{
exit;}
$img5= $_POST['img5']; //pl_img5
if ($img5==''){
$img5_nom= $_FILES["img5"]["name"];
$img5_pes= $_FILES["img5"]["size"];
$img5_temp= $_FILES["img5"]["tmp_name"];
}else{
exit;}
$img6 = $_POST['img6']; //pl_img6
if ($img6==''){
$img6_nom= $_FILES["img6"]["name"];
$img6_pes= $_FILES["img6"]["size"];
$img6_temp= $_FILES["img6"]["tmp_name"];
}else{
exit;}
$img7 = $_POST['img7']; //pl_img7
if ($img7==''){
$img7_nom= $_FILES["img7"]["name"];
$img7_pes= $_FILES["img7"]["size"];
$img7_temp= $_FILES["img7"]["tmp_name"];
}else{
exit;}
$contador = time();
//recepción de imágenes de http://blog.unijimpe.net/upload-de-archivos-con-php/
$errors=array();
if ($nom=="0") {$errors['nom']='nom';}
if ($nom2=="0") {$errors['nom2']='nom2';}
if ($pl_desc=="0") {$errors['pl_desc']='pl_desc';}
if ($ac_com=="0") {$errors['ac_com']='ac_com';}
if ($ac_desc=="0") {$errors['ac_desc']='ac_desc';}
if ($sr=="0") {$errors['sr']='sr';}
if ($fn=='') {$errors['fn']='fn';}
if ($en=="0") {$errors['en']='en';}
if ($dif=="0") {$errors['dif']='dif';}
if (count($errors)==0) {
//cargo imagenes
if (Empty($img1_nom)){
$upload_img1= null;
}else{
$upload_img1= "images/files/".$contador."_".$img1_nom;
if (move_uploaded_file($img1_temp, $upload_img1)){
$SQL_img1="INSERT INTO img (img_path, pl_id) values (E'".($upload_img1)."','".$pl_id."')";
$query = pg_exec($dbconn, $SQL_img1) or die (odbc_errormsg());
}
}
if (Empty($img2_nom)){
$upload_img2= null;
}else{
$upload_img2= "images/files/".$contador."_".$img2_nom;
if (move_uploaded_file($img2_temp, $upload_img2)){
$SQL_img2="INSERT INTO img (img_path, pl_id) values (E'".($upload_img2)."','".$pl_id."')";
$query = pg_exec($dbconn, $SQL_img2) or die (odbc_errormsg());
}
}
if (Empty($img3_nom)){
$upload_img3= null;
}else{
$upload_img3= "images/files/".$contador."_".$img3_nom;
if (move_uploaded_file($img3_temp, $upload_img3)){
$SQL_img3="INSERT INTO img (img_path, pl_id) values (E'".($upload_img3)."','".$pl_id."')";
$query = pg_exec($dbconn, $SQL_img3) or die (odbc_errormsg());
}
}
if (Empty($img4_nom)){
$upload_img4= null;
}else{
$upload_img4= "images/files/".$contador."_".$img4_nom;
if (move_uploaded_file($img4_temp, $upload_img4)){
$SQL_img4="INSERT INTO img (img_path, pl_id) values (E'".($upload_img4)."','".$pl_id."')";
$query = pg_exec($dbconn, $SQL_img4) or die (odbc_errormsg());
}
}
if (Empty($img5_nom)){
$upload_img5= null;
}else{
$upload_img5= "images/files/".$contador."_".$img5_nom;
if (move_uploaded_file($img5_temp, $upload_img5)){
$SQL_img5="INSERT INTO img (img_path, pl_id) values (E'".($upload_img5)."','".$pl_id."')";
$query = pg_exec($dbconn, $SQL_img5) or die (odbc_errormsg());
}
}
if (Empty($img6_nom)){
$upload_img6= null;
}else{
$upload_img6= "images/files/".$contador."_".$img6_nom;
if (move_uploaded_file($img6_temp, $upload_img6)){
$SQL_img6="INSERT INTO img (img_path, pl_id) values (E'".($upload_img6)."','".$pl_id."')";
$query = pg_exec($dbconn, $SQL_img6) or die (odbc_errormsg());
}
}
if (Empty($img7_nom)){
$upload_img7= null;
}else{
$upload_img7= "images/files/".$contador."_".$img7_nom;
if (move_uploaded_file($img7_temp, $upload_img7)){
$SQL_img7="INSERT INTO img (img_path, pl_id) values (E'".($upload_img7)."','".$pl_id."')";
$query = pg_exec($dbconn, $SQL_img7) or die (odbc_errormsg());
}
}
$SQL_pl="UPDATE pl_cl SET pl_nm='".addslashes($nom)."', pl_nm2='".addslashes($nom2)."',pl_desc='".addslashes($pl_desc)."', pl_hist='".addslashes($pl_hist)."', sr_id='".$sr."', fn_id='".$fn."', en_id='".$en."' where pl_cl.pl_id = '".$pl_id."'";
//$SQL_img="UPDATE img (img_path, pl_id) values (E'".($upload_img1)."','".$pl_id)."'";
$SQL_ac="INSERT INTO ac (ac_com, ac_desc, dif_id, pl_id) values('".addslashes($ac_com)."','".addslashes($ac_desc)."','".$dif."','".$pl_id."')";
$SQL_sv="INSERT INTO pl_cl_sv (pl_id, sv_id) values('".$pl_id."','".$sv[$o]."')";
$SQL_q="INSERT INTO pl_cl_q (pl_id, q_id) values('".$pl_id."','".$q[$i]."')";
$query_pl = pg_exec($dbconn, $SQL_pl) or die (odbc_errormsg());
$query_ac = pg_exec($dbconn, $SQL_ac) or die (odbc_errormsg());
$query_sv = pg_exec($dbconn, $SQL_sv) or die (odbc_errormsg());
$query_q = pg_exec($dbconn, $SQL_q) or die (odbc_errormsg());
echo "<div class='autenticat' style='position:absolute; right:150px;'>Datos entrados</div>";
}else{
echo "<div class='autenticat' style='position:absolute; right:150px;'>Problema al entrar los datos</div>";
}}