Visualizzazione dei risultati da 1 a 6 su 6

Discussione: Perchè non va?

  1. #1

    Perchè non va?

    Ciao a tutti, potreste controllare cosa non va in questo codice?
    ne mysql ne php mi danno errori però i dati che chiedo di inserire non vengono inseriti e non capisco il perchè

    codice:
    $RAZZA=$_POST['RAZZA'];
    .
    .
    .
    //Assegnazione Animale per i Lyarcon
    if ($RAZZA == 'Lyarcon'){
    $ANIMALE_NUM = mt_rand(1,6);
    	if ($ANIMALE_NUM == 1){
    	$ANIMALE == 'Falco';
    	}
    	elseif ($ANIMALE_NUM == 2){
    	$ANIMALE == 'Scimmia';
    	}
    	elseif ($ANIMALE_NUM == 3){
    	$ANIMALE == 'Lupo';
    	}
    	elseif ($ANIMALE_NUM == 4){
    	$ANIMALE == 'Orso';
    	}
    	elseif ($ANIMALE_NUM == 5){
    	$ANIMALE == 'Ermellino';
    	}
    	elseif ($ANIMALE_NUM == 6){
    	$ANIMALE == 'Riccio';
    	}
    }
    .
    .
    .
    .
    $sql = "INSERT INTO USERS 
           (CORPORAZIONE_TIPO,STATO_TIPO,FUNZIONE_TIPO,USERNAME,PASS,MAILREG,URLAVATAR,SESSO,RAZZA,URLSESSO,ESPERIENZA,SALUTE,BROWSER,ANIMALE,DATAREG,REGIP)
    VALUES ('$CORPORAZIONE_TIPO','$STATO_TIPO','$FUNZIONE_TIPO','$USERNAME','$PASS','$MAILREG','$URLAVATAR','$SESSO','$RAZZA','$URLSESSO','0','Sano','$_SERVER[HTTP_USER_AGENT]','$ANIMALE','$DATAREG','$_SERVER[REMOTE_ADDR]')";
    $query = @mysql_query ($sql, $connessione) or die(mysql_error());
    .
    .
    .
    Allora, dove ci sono i puntini è parte di codice che reputo poco importante per la domanda che vi porgo, spero sia vero, altrimenti fatemi sapere e vi invio la pagina intera.

    Cmq il problema è che nel database non viene registrata la variabile $ANIMALE, tutte le altre invece vengono registrate normalmente.

    PS: lasciate stare il fatto che sia tutto maiuscolo e altre cose inconsuete, è che sto modificando un gdr opensource, il resto funziona anke se così.
    Flash Developer for Rich Media
    PHP, jQuery Developer

  2. #2
    Codice PHP:
        if ($ANIMALE_NUM == 1){
        
    //ERRORE: $ANIMALE == 'Falco'; --> $ANIMALE = Falco; 

    fai così per tutti e 6



    p.s. nn usare più titoli del genere ai thread
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

  3. #3

    Re: Perchè non va?

    Originariamente inviato da Miroku
    PS: lasciate stare il fatto che sia tutto maiuscolo e altre cose inconsuete
    beh ... certo, considerando che PHP e' case sensitive diciamo che e' "ininfluente" ... posta la pagina
    Formaldehyde a new Ajax PHP Zero Config Error Debugger

    WebReflection @WebReflection

  4. #4
    Scusate per il titolo, non lo faccio + ^^;

    Cmq anche togliendo le due ' fa la stessa cosa, non inserisce nulla nel database.
    Ma non eri tu che sapevi il php? -.-
    giudichiamo solo noi stessi và, ke l'è meijo. :rollo:
    (ps: non c'è nessuno scherno in qst frasi, nn è mia intenzione discutere.)
    Flash Developer for Rich Media
    PHP, jQuery Developer

  5. #5
    mi son dimenticato l'allegato ^^;

    non ho possiblità di hostarlo per ora, vi mando tt il codice

    codice:
    <?
    /*#################################################
    Citt�virtuale GPL                                #
                                                      #
    Non rimuovere questo commento, grazie.            #
                                                      #
    Programmatore: (Traimo) Vladimir Inconis          #
    E-mail: traimo at weaponmaster dot org            #
    E-mail: traimo at laforzaoscura dot com           #
                                                      #
    Programmatore: (Prospero) Luca                    #
    E-mail: prosperocolonna_lot at hotmail dot com    #
                                                      #
    http://www.weaponmaster.org                       #
    http://www.laforzaoscura.com                      #
    http://www.steamcity.laforzaoscura.com            #
    */#################################################
    ?>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Citt&agrave; virtuale GPL</title>
    <link rel="stylesheet" href="stile.css" type="text/css">
    </head>
    
    <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <?PHP
    include "config.inc.php";
    
    $PRIMA=$_POST['PRIMA'];
    $USERNAME=$_POST['USERNAME'];
    $MAILREG=$_POST['MAILREG'];
    $SESSO=$_POST['SESSO'];
    $RAZZA=$_POST['RAZZA'];
    
    if ($PRIMA=='TRUE'){
    $USERNAME='';
    $MAILREG='';
    }
    else if ($PRIMA=='FALSE'){
     
    //LANCIO LA QUERY PER VERIFICARE L'ESISTENZA DELL'UTENTE 
    $sqlver = "SELECT * FROM USERS WHERE USERNAME = '$USERNAME'";
    $queryver = @mysql_query ($sqlver, $connessione) or die(mysql_error());
    $num_user = mysql_num_rows($queryver);
    
    //SE NON ESISTE PROCEDO CON LA VERIFICA DEI DATI E LA CREAZIONE
    if ($num_user == "0") {
    
    echo "<form name='formOK' method='post' action='login.php'>";
    echo "</form>";
    
    echo "<script language='Javascript'>";
    
    if (eregi("^[a-z]",$USERNAME)) {
    if (eregi("^[a-z0-9][_\.a-z0-9-]+@([a-z0-9][0-9a-z-]+\.)+([a-z]{2,4})",$MAILREG)){
    
    //Inserimento dati in DB
    
    /*GESTIONE SIMBOLO SESSO*/
    if ($SESSO=='Maschio')   $URLSESSO='http://localhost/opensource/grafica/mas.gif';
    if ($SESSO=='Femmina')   $URLSESSO='http://localhost/opensource/grafica/fem.gif';
    
    //Assegnazione Animale per i Lyarcon
    if ($RAZZA == 'Lyarcon'){
    $ANIMALE_NUM = mt_rand(1,5);
    	if ($ANIMALE_NUM == 1){
    	$ANIMALE == Falco;
    	}
    	elseif ($ANIMALE_NUM == 2){
    	$ANIMALE == Riccio;
    	}
    	elseif ($ANIMALE_NUM == 3){
    	$ANIMALE == Volpe;
    	}
    	elseif ($ANIMALE_NUM == 4){
    	$ANIMALE == Tigre;
    	}
    	elseif ($ANIMALE_NUM == 5){
    	$ANIMALE == Ermellino;
    	}
    }
    
    
    /*GESTIONE VARIABILI INIZIALI*/
    $URLAVATAR='http://localhost/opensource/grafica/init.gif';
    $CORPORAZIONE_TIPO='1';
    $STATO_TIPO='1';
    $FUNZIONE_TIPO='5';
    
    /*GESTIONE E CREAZIONE PASSWORD*/
    function randomPassword () {
            $length ="8";
            $possible = '23456789' . 
    	            'abcdefghijkmnpqrstuvwxyz' .
    		    'ABCDEFGHJKLMNPQRSTUVWXYZ';
            $str ="";
            while (strlen($str) < $length) {
    		$str.=substr($possible, (rand() % strlen($possible)),1);
       }
             return($str);
    }
    $PASS=randomPassword();
    
    /*GESTIONE DATA DI REGISTRAZIONE*/
    // setto data e ora in base alla linga locale
    setlocale (LC_TIME,"it_IT");
    // metto data e ora in un array
    $DATA1 = time();
    
    $date_time_array = getdate($DATA1);
    
    $hours = $date_time_array['hours'];
    $minutes = $date_time_array['minutes'];
    $seconds = $date_time_array['seconds'];
    $month = $date_time_array['mon'];
    $day = $date_time_array['mday'];
    $year = $date_time_array['year'];
    
    $DATA1 = mktime($hours,$minutes,$seconds,$month,$day,$year);
    //echo strftime('%H : %M - %A %d %B %Y',$DATA_PROBLEMA);
    //fine formattazione data
    $DATAREG = strftime('%H : %M - %d/%m/%y',$DATA1);
    
    $USERNAME = str_replace("'", "&#0039;", $USERNAME);
    
    $sql = "INSERT INTO USERS 
           (CORPORAZIONE_TIPO,STATO_TIPO,FUNZIONE_TIPO,USERNAME,PASS,MAILREG,URLAVATAR,SESSO,RAZZA,URLSESSO,ESPERIENZA,SALUTE,BROWSER,ANIMALE,DATAREG,REGIP)
    VALUES ('$CORPORAZIONE_TIPO','$STATO_TIPO','$FUNZIONE_TIPO','$USERNAME','$PASS','$MAILREG','$URLAVATAR','$SESSO','$RAZZA','$URLSESSO','0','Sano','$_SERVER[HTTP_USER_AGENT]','$ANIMALE','$DATAREG','$_SERVER[REMOTE_ADDR]')";
    $query = @mysql_query ($sql, $connessione) or die(mysql_error());
    
    /*INVIO MAIL CON I DATI DI REGISTRAZIONE*/
    $sender_name = "STAFF - Phyrosia";
    $sender_email = "phyrosiastaff@hotmail.it";
    $dati_accesso = "Dati di accesso di Phyrosia";
    $msg = "Da:\t$sender_name\n";
    $msg .= "\n";	
    $msg .= "E-mail:\t$sender_email\n";
    $msg .= "\n";	
    $msg .= "Oggetto:\t$dati_accesso\n";
    $msg .= "\n";	
    $msg .= "\n";	
    $msg .= "Username:\t$USERNAME\n";
    $msg .= "\n";	
    $msg .= "Password:\t$PASS\n\n"; 
    $msg .= "\n";
    $msg .= "Ti ricodiamo la pagina di accesso a Phyrosia http://localhost/opensource\n";
    $msg .= "\n";	
    $mailheaders = "Form inviato dal servizio registrazione utenti di Citt�virtuale GPL\n";
    $mailheaders .= "Rispondi a: $sender_email\n\n";
    mail($MAILREG, "Form inviato dal servizio registrazione utenti di Citt�virtuale GPL", $msg, $mailheaders);
    
    echo "document.formOK.submit();";
    echo "alert ('Operazione eseguita correttamente.')";
    }else{ echo "alert ('E-mail non valida.')";}
    }else{ echo "alert ('Nickname non valido.')";}
    echo "</script>";
    }
    
    else if ($num_user == "1"){
    echo "<form name='formESISTE' method='post' action='registra_utente.php'>";
    echo "</form>";
    echo "<script language='Javascript'>";
    echo "alert ('Nickname gi�presente del database! Provare con un altro nickname.');";
    echo "document.formESISTE.submit();";
    echo "</script>";
    }
    }
    
    
    
    //Avviso l'admin che si è registrato un nuovo utente
    $TO_POSTA= "admin";
    $FROM_POSTA= "Sistema";
    $OBJ_POSTA= "Nuovo utente registrato";
    $MSG_POSTA= "Si èregistrato un nuovo utente, il suo nick è '$USERNAME'";
    
    $MSG_POSTA = str_replace("<", "&lt;", $MSG_POSTA);
    $MSG_POSTA = str_replace(">", "&gt;", $MSG_POSTA);
    $MSG_POSTA = str_replace("'", "&#0039;", $MSG_POSTA);
    $MSG_POSTA = nl2br($MSG_POSTA);
    
    //$DATA_POSTA = date ("d/m/Y H:i:s");
    //formattazione data
    // setto data e ora in base alla lingua locale
    setlocale (LC_TIME,"it_IT");
    
    // metto data e ora in un array
    $DATAORIG = time();
    
    $date_time_array = getdate($DATAORIG);
    
    $hours = $date_time_array['hours'];
    $minutes = $date_time_array['minutes'];
    $seconds = $date_time_array['seconds'];
    $month = $date_time_array['mon'];
    $day = $date_time_array['mday'];
    $year = $date_time_array['year'];
    // aggiungo 7 ore all'orario del server per avere l'ora corretta in Iralia
    $DATAORIG = mktime($hours + 7,$minutes,$seconds);
    //fine formattazione data
    $DATA_POSTA = strftime('%H : %M - %A %d %B %Y',$DATAORIG);
    
    $sql = "INSERT INTO POSTA (FROM_POSTA,TO_POSTA,OBJ_POSTA,MSG_POSTA,DATA_POSTA,NEW_POSTA) VALUES ('$FROM_POSTA','$TO_POSTA','$OBJ_POSTA','$MSG_POSTA','$DATA_POSTA','1')";
    $query = @mysql_query ($sql, $connessione) or die(mysql_error());
    
    @mysql_close ($connessione);
    ?>
    <table width="100%" border="0" cellspacing="0" cellpadding="5" align="center">
      <tr>
        <td height="50" align="center" class="RedTIT">SPAZIO RISERVATO AL BANNER</td>
      </tr>
      <tr>
        <td height="50" align="center" class="RedTIT">.: Nuovo giocatore :.</td>
      </tr>
      <form name="form1" method="post" action="registra_utente.php">
        <tr>
          <td height="50" align="center"><table width="550" border="0" cellspacing="0" cellpadding="1" bgcolor="000000">
              <tr>
                <td><table border="0" width="570" cellspacing="0" bordercolorlight="#01273F" cellpadding="5" bgcolor="#ffffff">
                    <tr>
                      <td width="275" height="20" class="RedB">Nome del PG (nickname):</td>
                      <td width="275" height="20"><input name="USERNAME" type="text" class="textfieldBASE" id="USERNAME" value="<?=$USERNAME?>" size="20" maxlength="20">
                      </td>
                    </tr>
                    <tr>
                      <td height="20" class="RedB">Sesso:</td>
                      <td height="20">
    				    <select name="SESSO" class="textfieldBASE" id="SESSO">
                        <option value="Maschio" selected>Maschio</option>
                        <option value="Femmina">Femmina</option>
                        </select></td>
    		<tr>
    		<td height="20" class="RedB">Razza:
    		</td>
    		<td>
    				<select name="RAZZA" class="textfieldBASE" id="RAZZA">
    			<option value="Umano" selected>Umano</option>
    			<option value="Elfo">Elfo</option>
    			<option value="MezzElfo">Mezz'Elfo</option>
    			<option value="Fata">Fata</option>
    			<option value="MezzoDrow">Mezzo Drow</option>
    			<option value="Lyarcon">Lyarcon</option>
    				</select>
    				  </td>
    		</tr>
                    </tr>
                    <tr>
                      <td height="20" class="RedB">E-mail:</td>
                      <td height="20"><input name="MAILREG" type="text" class="textfieldBASE" id="MAILREG" value="<?=$MAILREG?>" size="20" maxlength="255">
                      </td>
                    </tr>
                    <tr>
                      <td height="20" colspan="2" align="center" class="RedB">
    				  <input name="PRIMA" type="hidden" id="PRIMA" value="FALSE">
                      <input type="submit" value="Registra" class="textfieldBASE" name="submit"></td>
                    </tr>
                </table></td>
              </tr>
          </table></td>
        </tr>
      </form>
      <tr>
        <td height="50" align="center" valign="middle">Torna alla pagina di login </td>
      </tr>
    </table>
    </body>
    </html>
    Flash Developer for Rich Media
    PHP, jQuery Developer

  6. #6
    Riscrivi il thread con un titolo a norma di regolamento, grazie
    Addio Aldo, amico mio... [03/12/70 - 16/08/03]

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.