Dopo avere risolto il problema di post delle news, ora mi si presenta un ulteriore dilemma, ho modificato il mio script per poter modificare o cancellare degli articoli

script:

Codice PHP:
/* connessione al database */
   
$db mysql_connect ('localhost','.....','..........');
   
mysql_select_db ('........',$db);
    
   
//-----------------------------------------------------------------------------------------------------------    
   // MODULO INSERIMENTO DELLE NEWS
   //-----------------------------------------------------------------------------------------------------------    
   /* form inserimento news */
   
function formInsert() {
      echo 
"<TABLE border=\"0\" width=\"100%\">\n";
      echo 
"<TR><TD><span class=\"Stile2\">MODULO INSERIMENTO NEWS</span></span>

</TD></TR>\n"
;
      echo 
"<TR><TD><FORM action=\"index.php?lng=it&cdx=chk&skip=ok&action=addnews\" method=POST>\n";
      echo 
"Titolo
<input type=\"text\" " 
.
         
"width=\"30\" name=\"titolo\">
\n"
;
      echo 
"
Articolo
<TEXTAREA cols=\"40\" rows=\"10\" " 
.
         
"name=\"articolo\"></TEXTAREA>
\n"
;
      echo 
"
<input type=\"submit\" name=\"submit\" " 
.
         
"value=\"Inserisci\"\n";
      echo 
"</FORM></TD></TR>\n";
      echo 
"</TABLE>\n";
      }
      
   
/* funzione inserimento news */
   
function insertNews() {
      global 
$db;
      
      
/* inseriamo la news nella tabella */
      
$query "INSERT INTO news(postdate, title, newstext) VALUES(now(),'$_POST[titolo]','$_POST[articolo]')";
      
mysql_query($query)  or die("Query non valida: " mysql_error());
     
      echo 
"<TABLE border=\"0\" width=\"100%\">\n";
      echo 
"<TR><TD><span class=\"Stile2\">MODULO INSERIMENTO NEWS</span></span>

</TD></TR>\n"
;
      echo 
"<TR><TD>News inserita. Grazie!

\n"
;
      echo 
"<a href=\"index.php?lng=it&cdx=chk&skip=ok\">Amministrazione</a></TD></TR>\n";
      echo 
"</TABLE>\n";
      }
   
//-----------------------------------------------------------------------------------------------------------    
   //-----------------------------------------------------------------------------------------------------------    
    
   //-----------------------------------------------------------------------------------------------------------
   // MODULO CANCELLAZIONE NEWS E ARTICOLI    
   //-----------------------------------------------------------------------------------------------------------      
   /* funzione cancella news */
   
function deleteNews($item) {
      global 
$db;
      
      
/* cancello la news nella tabella e i commenti */
      
mysql_query ("DELETE FROM news WHERE id = '$_POST[item]'") or die ( "Non riesco ad eseguire la richiesta");
      
mysql_query ("DELETE FROM news_comments WHERE news_id = '$_POST[item]'") or die ( "Non riesco ad eseguire la richiesta"); 
     
      echo 
"<TABLE border=\"0\" width=\"100%\">\n";
      echo 
"<TR><TD><span class=\"Stile2\">MODULO ELIMINAZIONE NEWS</span></span>

</TD></TR>\n"
;
      echo 
"<TR><TD>News e commenti cancellati. Grazie!

\n"
;
      echo 
"<a href=\"index.php?lng=it&cdx=chk&skip=ok\">Amministrazione</a></TD></TR>\n";
      echo 
"</TABLE>\n";
      }    
      
      
/* form cancella news */
   
function formDelete() {
      global 
$db;
      
      
/* recupero le news */
      
$query "SELECT *" 
               
"DATE_FORMAT(postdate, '%d-%m-%Y') as date " .
               
"FROM news ORDER BY postdate DESC";
      
$result mysql_query ($query);
      echo 
"<TABLE border=\"0\" width=\"100%\">\n";
      echo 
"<TR><TD>Commenti:</TD></TR>\n";
      echo 
"</TABLE>\n";
      echo 
"
\n"
;
      echo 
"<TABLE border=\"0\" width=\"100%\">\n";
      echo 
"<TR><TD><span class=\"Stile2\">MODULO ELIMINAZIONE NEWS</span></span>

</TD></TR>\n"
;
    
      
/* visualizzo form selezione */
      
while ($row mysql_fetch_assoc ($result)) {
        
$id $row['id'];
        
$titolo htmlentities ($row['title']);
        
$data $row['date'];
        echo 
"<TR><TD><FORM action=\"index.php?lng=it&cdx=chk&skip=ok&action=delnews\" method=POST>\n";
        echo 
"<input type=hidden name=\"item\" value=\"'.$id.'\">[b]$titolo[/b] $data</TD><TD><input type=\"submit\" name=\"submit\" value=\"Cancella\"</TD>\n";
        echo 
"</FORM></TD></TR>\n";
        }
      echo 
"</TD></TR></TABLE>\n";
      }    
   
//-----------------------------------------------------------------------------------------------------------    
   //-----------------------------------------------------------------------------------------------------------
   
   //-----------------------------------------------------------------------------------------------------------    
   // MODULO MODIFICA NEWS
   //-----------------------------------------------------------------------------------------------------------
   /* form selezione news */
   
function selectEdit() {
      global 
$db;
   
/* recupero le news */
   
$query "SELECT *" 
            
"DATE_FORMAT(postdate, '%d-%m-%Y') as date " .
            
"FROM news ORDER BY postdate DESC";
    
$result mysql_query ($query);
      echo 
"<TABLE border=\"0\" width=\"100%\">\n";
      echo 
"<TR><TD>Commenti:</TD></TR>\n";
      echo 
"</TABLE>\n";
      echo 
"
\n"
;
      echo 
"<TABLE border=\"0\" width=\"100%\">\n";
      echo 
"<TR><TD><span class=\"Stile2\">MODULO MODIFICA NEWS</span></span>

</TD></TR>\n"
;
                
      
/* visualizzo form selezione */
      
while ($row mysql_fetch_assoc ($result)) {
        
$id $row['id'];
        
$titolo htmlentities ($row['title']);
        
$data $row['date'];
        echo 
"<TR><TD><FORM action=\"index.php?lng=it&cdx=chk&skip=ok&action=formEdit\" method=POST>\n";
        echo 
"<input type=hidden name=\"item\" value=\"'.$id.'\">[b]$titolo[/b] $data</TD><TD><input type=\"submit\" name=\"submit\" value=\"Cancella\"</TD>\n";
        echo 
"</FORM></TD></TR>\n";
        }
      echo 
"</TD></TR></TABLE>\n";
      }    
      
   
/* form modifica news */
   
function formEdit($item) {
      global 
$db;
   
/* recupero le news */
   
$query "SELECT *" 
            
"FROM news WHERE id = '$_POST[item]'";
    
$result mysql_query ($query);
      echo 
"<TABLE border=\"0\" width=\"100%\">\n";
      echo 
"<TR><TD>Commenti:</TD></TR>\n";
      echo 
"</TABLE>\n";
      echo 
"
\n"
;
      echo 
"<TABLE border=\"0\" width=\"100%\">\n";
      echo 
"<TR><TD><span class=\"Stile2\">MODULO MODIFICA NEWS</span></span>

</TD></TR>\n"
;
                
      
/* visualizzo form selezione */
      
while ($row mysql_fetch_assoc ($result)) {
        
$id $row['id'];
        
$titolo htmlentities ($row['title']);
        
$articolo nl2br ($row['newstext']);        
        echo 
"<TR><TD><FORM action=\"index.php?lng=it&cdx=chk&skip=ok&action=upnews\" method=POST>\n";
        echo 
"Titolo
<input type=\"text\" " 
.
         
"width=\"30\" name=\"titolo\" value=\"'.$titolo.'\">
\n"
;
        echo 
"
Articolo
<TEXTAREA cols=\"40\" rows=\"10\" " 
.
         
"name=\"articolo\" value=\"'.$articolo.'\"></TEXTAREA>
\n"
;
        echo 
"
<input type=\"submit\" name=\"submit\" " 
.
         
"value=\"Inserisci\"\n";
        echo 
"<input type=hidden name=\"item\" value=\"'.$id.'\">\n";
        echo 
"</FORM></TD></TR>\n";        
        }
      echo 
"</TD></TR></TABLE>\n";
      }    
   
   
/* funzione edita news */
   
function editNews($item) {
      global 
$db;
      
      
/* aggiorniamo la news nella tabella */
      
mysql_query("UPDATE news SET newstext = '$_POST[articolo]' WHERE id = '$_POST[item]'") or die ( "Non riesco ad eseguire la richiesta"); 
      
mysql_query("UPDATE news SET title = '$_POST[titolo]' WHERE id = '$_POST[item]'") or die ( "Non riesco ad eseguire la richiesta");
      
      echo 
"<TABLE border=\"0\" width=\"100%\">\n";
      echo 
"<TR><TD><span class=\"Stile2\">MODULO INSERIMENTO NEWS</span></span>

</TD></TR>\n"
;
      echo 
"<TR><TD>News modificata. Grazie!

\n"
;
      echo 
"<a href=\"index.php?lng=it&cdx=chk&skip=ok\">Amministrazione</a></TD></TR>\n";
      echo 
"</TABLE>\n";
      }
   
//-----------------------------------------------------------------------------------------------------------    
   //-----------------------------------------------------------------------------------------------------------
   
   /* funzione start */
   
function manageNews() {
      
      echo 
"<TABLE border=\"0\" width=\"100%\">\n";
      echo 
"<TR><TD><span class=\"Stile2\">MODULO GESTIONE NEWS</span></span>

</TD></TR>\n"
;
      echo 
"<TR><TD><a href=\"index.php?lng=it&cdx=chk&skip=ok&action=formInsert\">Inserisci News</a>
<a href=\"index.php?lng=it&cdx=chk&skip=ok&action=selectEdit\">Modifica News</a>
<a href=\"index.php?lng=it&cdx=chk&skip=ok&action=formDelete\">Cancella News</a></TD></TR>\n"
;
      echo 
"</TABLE>\n";
      }
   
   
//-----------------------------------------------------------------------------------------------------------    
   /* questa è la parte dello script dove viene presa la decisione di che cosa fare */
   //-----------------------------------------------------------------------------------------------------------
   
echo "<CENTER>\n";
   switch(
$_GET['action']) {
    
        
/* moduli inserimento news */
       
case 'addnews':
            
insertNews();
            break;
       case 
'formInsert':
            
formInsert();
            break;
       
/* moduli modifica news */
       
case 'upnews':
            
editNews($_GET['item']);
            break;
       case 
'selectEdit':
            
selectEdit();
            break;
       case 
'formEdit':
            
formEdit($_GET['item']);
            break;
       
/* moduli cancella news */   
       
case 'delnews':
            
deleteNews($_GET['item']);
            break;
       case 
'formDelete':
            
formDelete();
            break;
       default:
              
manageNews();
      }
   echo 
"</CENTER>\n";
   
//-----------------------------------------------------------------------------------------------------------
   //-----------------------------------------------------------------------------------------------------------
   

Quando dalla pagina iniziale manageNews vado a selezionare il link modifica o cancella
mi arriva l'errore:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/ftp-ataca/torinofreetime.com/index.php on line ...

in entrambi i casi corrispondono alle righe:

Codice PHP:
while ($row mysql_fetch_assoc ($result)) { 
dei moduli modifica e cancellazione nelle funzioni selectEdit e formDelete.

Avrei cortesemente bisogno di capire nel mio script dove è l'errore, piu precisamente qui:

Codice PHP:
/* form cancella news */
   
function formDelete() {
      global 
$db;
      
      
/* recupero le news */
      
$query "SELECT *" 
               
"DATE_FORMAT(postdate, '%d-%m-%Y') as date " .
               
"FROM news ORDER BY postdate DESC";
      
$result mysql_query ($query);
      echo 
"<TABLE border=\"0\" width=\"100%\">\n";
      echo 
"<TR><TD>Commenti:</TD></TR>\n";
      echo 
"</TABLE>\n";
      echo 
"
\n"
;
      echo 
"<TABLE border=\"0\" width=\"100%\">\n";
      echo 
"<TR><TD><span class=\"Stile2\">MODULO ELIMINAZIONE NEWS</span></span>

</TD></TR>\n"
;
    
      
/* visualizzo form selezione */
      
while ($row mysql_fetch_assoc ($result)) {
        
$id $row['id'];
        
$titolo htmlentities ($row['title']);
        
$data $row['date'];
        echo 
"<TR><TD><FORM action=\"index.php?lng=it&cdx=chk&skip=ok&action=delnews\" method=POST>\n";
        echo 
"<input type=hidden name=\"item\" value=\"'.$id.'\">[b]$titolo[/b] $data</TD><TD><input type=\"submit\" name=\"submit\" value=\"Cancella\"</TD>\n";
        echo 
"</FORM></TD></TR>\n";
        }
      echo 
"</TD></TR></TABLE>\n";
      }