Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
PHP - ELIMINAZIONE DI UN RECORD
Forum - PHP - ELIMINAZIONE DI UN RECORD

Avatar
Ilvince (Normal User)
Newbie


Messaggi: 8
Iscritto: 16/09/2011

Segnala al moderatore
Postato alle 17:31
Giovedì, 27/10/2011
ho un problema che non riesco a uscirne fuori mi da questo errore quando ho cancellato un record :

Warning: Invalid argument supplied for foreach() in C:\Programmi\Apache Software Foundation\Apache2.2\htdocs\lprova\management.php on line 2286


Codice sorgente - presumibilmente Php

  1. case 'modify_offert_form':
  2.         $id_offert = $_POST['activity_id'];
  3.         $id_remove_offert = $_POST['activity_remove'];
  4.     if (is_not_null_not_blank($id_offert))
  5.         {       if (is_not_null_not_blank($id_remove_offert))
  6.                         $testo_offert = "Rimozione di un messaggio nella pagina Offerte";
  7.                 else
  8.                         $testo_offert = "Modifica di un messaggio nella pagina Offerte";
  9.                 $offert = $db->query_single_object("SELECT * FROM attributes WHERE attributes.attribute_id = $id_offert");
  10.                 $name_offert = $offert->title;
  11.                 $description_offert = $offert->description;
  12.                 $order_offert = $offert->priority;
  13.         }
  14.         else
  15.         {
  16.                 $testo_offert = "Inserimento di un messaggio nella pagina Offerte";
  17.                 $order_offert = 1;
  18.         }
  19.         ?>
  20.         <h2><? echo($testo_offert); ?></h2><hr class="title_line" />
  21.         <form action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post">
  22.                 Nome Offerta:<br />
  23.                 <input type="text" name="nome_offert" <?php if($id_remove_offert) echo ("readonly='true'");?>" value="<?php echo $name_offert; ?>" style="width:400px;" />
  24.                 <br /><br />
  25.                 Ordine:<br />
  26.                 <input type="number" name="ordine_offert" <?php if($id_remove_offert) echo ("readonly='true'");?>" min="1" max="10000" step="1" value="<?php echo $order_offert; ?>" style="width:50px;" />
  27.                 <br /><br />
  28.                 Descrizione:<br />
  29.                 <textarea name="descrizione_offert" <?php if($id_remove_offert) echo ("readonly='true'");?>" rows=6 style="width:400px;">
  30.                         <?echo(trim($description_offert));?>
  31.                 </textarea>
  32.                 <br /><br />
  33.                 <input type="hidden" name="activity" value="modify_offert_execution" />
  34.                 <input type="hidden" name="activity_id" value="<?php echo $id_offert; ?>" />
  35.                 <input type="hidden" name="activity_remove" value="<?php echo $id_remove_offert; ?>" />
  36.                 <?
  37.                         if (is_not_null_not_blank($id_offert))
  38.                         {
  39.                                 if (is_not_null_not_blank($id_remove_offert))
  40.                                         echo "<input type='submit' value='Rimuovi' />";
  41.                                 else
  42.                                         echo "<input type='submit' value='Aggiorna' />";
  43.                         }
  44.                         else
  45.                                 echo "<input type='submit' value='Salva' />";
  46.                        
  47.                         if (!is_not_null_not_blank($id_remove_offert))
  48.                                 echo ("<input type='reset' value='Ripristina' />");
  49.                 ?>
  50.                
  51.         </form>
  52.         <?php
  53.         break;



//e da qui poi passa i parametri qua

Codice sorgente - presumibilmente Php

  1. case 'modify_offert_execution':
  2.         # Controllo che nessuno dei settaggi sia vuoto o nullo.
  3.         if (!(is_not_null_not_blank($_POST['nome_offert']) &&
  4.                         is_not_null_not_blank($_POST['ordine_offert']))) {
  5.                 echo(management_message('Attenzione!', 'Tutti i campi sono obbligatori.'));
  6.                 # Impostazione del valore di $error, per creare correttamente
  7.                 # il tasto di reindirizzamento a fondo pagina.
  8.                 $error = TRUE;
  9.                 break;
  10.         }
  11.        
  12.         # Reimpostazione vera e propria dei settaggi.
  13.         try {
  14.                 $nome_offert = trim($_POST['nome_offert']);
  15.                 $ordine_offert = $_POST['ordine_offert'];
  16.                 $descrizione_offert = trim($_POST['descrizione_offert']);
  17.                 $id_offert = $_POST['activity_id'];
  18.                 $id_remove_offert = $_POST['activity_remove'];
  19.                
  20.                 if (is_not_null_not_blank($id_offert))
  21.                 {
  22.                         if (is_not_null_not_blank($id_remove_offert))
  23.                         {
  24.                                 $file_offert_array = $db->query_objects_array("SELECT * FROM files WHERE files.attribute_id = $id_offert");
  25.                                 # Recupero la path
  26.                                 $pathimage = substr($_SERVER['SCRIPT_FILENAME'], 0, strlen($_SERVER['SCRIPT_FILENAME']) - strlen(strrchr($_SERVER['SCRIPT_FILENAME'], "/")));
  27. //RIGA 2286
  28. foreach ($file_offert_array as $file_offert_array_element)
  29.                                 {
  30.                                         unlink("$pathimage/files/$file_offert_array_element->name");
  31.                                         $db->query_no_result("DELETE FROM files WHERE file_id = $file_offert_array_element->file_id");
  32.                                 }
  33.                                 $db->query_no_result("DELETE FROM attributes WHERE attribute_id = $id_offert");
  34.                         }
  35.                         else
  36.                                 $db->query_no_result("UPDATE attributes SET title = '$nome_offert', priority = '$ordine_offert', description = '$descrizione_offert' WHERE attribute_id = $id_offert");
  37.                 }
  38.                 else
  39.                         $db->query_no_result("INSERT INTO attributes (title,description,priority,sector_id) VALUES ('$nome_offert','$descrizione_offert',$ordine_offert,3)");
  40.                        
  41.                 echo(management_message('Operazione completata',
  42.                                                                 'Modifica dela offerta eseguita con successo.<br /><br />'));
  43.         } catch(Exception $e) {
  44.                 echo(management_message('Attenzione!', 'Modifica del messaggio chi siamo eseguita senza successo.' .
  45.                                                                         '<br />' . $e->getMessage()));
  46.                 # Impostazione del valore di $error, per creare correttamente
  47.                 # il tasto di reindirizzamento a fondo pagina.
  48.                 $error = TRUE;
  49.         }
  50.         break;



grazie a tuttiiiii

Ultima modifica effettuata da Il Totem il 28/10/2011 alle 11:30
PM
Avatar
Il Totem (Admin)
Guru^2


Messaggi: 3635
Iscritto: 24/01/2006

Up
1
Down
V
Segnala al moderatore
Postato alle 11:33
Venerdì, 28/10/2011
$file_offert_array non è un array oppure è null.

per nasconderlo?? - Ilvince - 28/10/11 12:07
Per nasconderlo? Cosa significa? - Il Totem - 29/10/11 13:08
PM
Avatar
Mte90 (Member)
Guru


Messaggi: 1144
Iscritto: 25/03/2008

Up
0
Down
V
Segnala al moderatore
Postato alle 18:01
Giovedì, 27/10/2011
a parte il tag per il codice sbagliato la riga in questione che dà problemi qual'è?

PM