Salve ragazzi scrivo per chiedervi aiuto riguardo un problema a mio avviso stranuccio. Praticamente mi sono creato una tabella "classifiche" nella quale devo inserire dei dati, eccovi la sua struttura:

Codice PHP:
CREATE TABLE classifiche (
  
song_id tinyint(3unsigned NOT NULL default '0',
  
user_id mediumint(8NOT NULL default '0',
  
song_pos tinyint(3unsigned NOT NULL default '0',
  
song_title varchar(50NOT NULL default '',
  
song_author varchar(50NOT NULL default '',
  
song_type varchar(20NOT NULL default '',
  
song_insdate int(11NOT NULL default '0',
  
song_votes smallint(5unsigned NOT NULL default '0',
  
PRIMARY KEY  (song_id),
  
KEY user_id (user_id)
TYPE=MyISAM
Ovviamente dopo mi sono creato un form per l'inserimento dei dati:

Codice PHP:
<form name="classifiche" method="post" action="classifiche.php?mode=ins">
      
Titolo:
          <
input name="song_title" type="text" maxlength="50">
          
Autore:
          <
input name="song_author" type="text" maxlength="50">
          
Genere
          <
select name="song_type" id="song_type">
            <
option value="salsa">Salsa</option>
          </
select>
          <
input name="Submit" type="submit" class="button" value="Invia">
    </
form
Come vedete i dati vengono passati con metodo post alla pagina che mediante script php effettua la query d'inserimento: (ecco il codice per l'inserimento)

Codice PHP:
if ($mode == 'ins') {
   
$Result mysql_query("SELECT MAX(song_id) as song_id , MAX(song_pos) as song_pos from classifiche");
   if (!
$Result) { die(mysql_error()); }
   
$rs mysql_fetch_row($Result);
   
$song_id $rs['song_id'] + 1;
   
$song_pos $rs['song_pos'] + 1;
   
$user_id $userdata['user_id'];
   
$song_title trim(htmlspecialchars($HTTP_POST_VARS['song_title']));
   
$song_author trim(htmlspecialchars($HTTP_POST_VARS['song_author']));
   
$song_type trim(htmlspecialchars($HTTP_POST_VARS['song_type']));
   
$Result mysql_query("INSERT INTO classifiche (song_id,user_id,song_pos,song_title,song_author,song_type,song_insdate) 
   VALUES (
$song_id,$user_id,$song_pos,'" str_replace("\'""''"$song_title) . "','" str_replace("\'""''"$song_author) . "','$song_type'," time() . ")");
   if (!
$Result) { die(mysql_error()); } 

Il problema di cui vi parlavo consiste nel fatto che tutti i dati mi vengono inseriti nella tabella solo una volta poi se tento di effettuare un nuovo inserimento, alla tabella non viene aggiunto nulla! Mi sapreste dire come mai?