Visualizzazione dei risultati da 1 a 8 su 8

Discussione: Errore in Contatore

  1. #1

    Errore in Contatore

    dov'è l'errore in questo codice di freephp?
    codice:
    <?php
    // Simple text counter by RaS! (ras78@libero.it) 
    
    $counterfile="contatore.txt";
    if (!file_exists($counterfile))
     {
      $stack=1;
      $file=fopen($counterfile,"w+");
      fputs($file,$stack);
      fclose($file);  
     } else {
      $file=fopen($counterfile,"r");
      $tot=fgets($file,20);
      $tot++;
      fclose($file);
      $file=fopen($counterfile,"w+");
      $tot=fputs($file,$tot);  
      fclose($file);
     }
    ?>
    Non mi da nessun errore...ma neanche funziona...non mi mostra nulla, eppure il file l'ho creato...
    Il mio sito: CIONCO.ALTERVISTA.ORG
    Lloyd Bank$
    I roll with the gangstas don't get fly with your mouth
    The wrong punchline'll have niggas inside of your house

  2. #2
    non c'è errore, lo script funziona.

    tu cos'è che vuoi ottenere?

  3. #3
    Originariamente inviato da Tymba
    non c'è errore, lo script funziona.

    tu cos'è che vuoi ottenere?
    emh...il numero di accessi ad una pagine...un contatore d'accessi insomma...
    Il mio sito: CIONCO.ALTERVISTA.ORG
    Lloyd Bank$
    I roll with the gangstas don't get fly with your mouth
    The wrong punchline'll have niggas inside of your house

  4. #4
    ahhhh ora è tutto più chiaro.

    prende un numero e lo scrive in un file
    la seconda volta legge sto numero, lo incrementa e lo riscrive nel file

    non c'è un'istruzione che lo stampa.
    Basta che fai
    echo $tot;

    ed hai risolto il problema

  5. #5
    Originariamente inviato da Tymba
    ahhhh ora è tutto più chiaro.

    prende un numero e lo scrive in un file
    la seconda volta legge sto numero, lo incrementa e lo riscrive nel file

    non c'è un'istruzione che lo stampa.
    Basta che fai
    echo $tot;

    ed hai risolto il problema
    l'avevo già fatto ma mi mostra sempre 2...
    Il mio sito: CIONCO.ALTERVISTA.ORG
    Lloyd Bank$
    I roll with the gangstas don't get fly with your mouth
    The wrong punchline'll have niggas inside of your house

  6. #6
    ho risolto con un include del file txt
    Il mio sito: CIONCO.ALTERVISTA.ORG
    Lloyd Bank$
    I roll with the gangstas don't get fly with your mouth
    The wrong punchline'll have niggas inside of your house

  7. #7
    http://www.valeriocarnevali.it/contatore.php

    qui c'è il tuo script vedrai che il contatore si incrementa

    <?php
    // Simple text counter by RaS! (ras78@libero.it)

    $counterfile="contatore.txt";
    if (!file_exists($counterfile))
    {
    $stack=1;
    $file=fopen($counterfile,"w+");
    fputs($file,$stack);
    fclose($file);
    } else {
    $file=fopen($counterfile,"r");
    $tot=fgets($file,20);
    $tot++;
    echo $tot;
    fclose($file);
    $file=fopen($counterfile,"w+");
    $tot=fputs($file,$tot);
    fclose($file);
    }
    ?>

  8. #8
    <?php
    $file = 'utenti.txt';
    $fp = fopen( $file, 'r+' );
    settype( $num = fread( $fp, filesize( $file ) ), "float" );
    fseek($fp, 0);
    fwrite( $fp, ++$num );
    fclose( $fp );


    // il numero utenti
    echo $num;
    ?>
    Formaldehyde a new Ajax PHP Zero Config Error Debugger

    WebReflection @WebReflection

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 © 2025 vBulletin Solutions, Inc. All rights reserved.