Pagina 1 di 5 1 2 3 ... ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 42

Discussione: Non capisco errore

  1. #1
    Utente bannato L'avatar di Braco
    Registrato dal
    Oct 2005
    Messaggi
    1,697

    Non capisco errore

    Qualcuno può spiegarmi xchè mi da errore function: iptocountry() eppure la funzione è stata dichiarata:

    Codice PHP:
    $IPaddress=$_SERVER['REMOTE_ADDR']; 
    $two_letter_country_code=iptocountry($IPaddress);
      
    include(
    "ip_files/countries.php");
    $three_letter_country_code=$countries$two_letter_country_code][0];
    $country_name=$countries[$two_letter_country_code][1];

    print 
    "Two letters code: $two_letter_country_code
    "
    ;
    print 
    "Three letters code: $three_letter_country_code
    "
    ;
    print 
    "Country name: $country_name
    "
    ;

    // To display flag
    $file_to_check="flags/$two_letter_country_code.gif";
    if (
    file_exists($file_to_check)){
                    print 
    "<img src=$file_to_check width=20 height=15>
    "
    ;
                    }else{
                    print 
    "<img src=flags/noflag.gif width=20 height=15>
    "
    ;
                    }

    function 
    iptocountry($ip) {
        
    $numbers preg_split"/\./"$ip);
        include(
    "ip_files/".$numbers[0].".php");
        
    $code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]);
        foreach(
    $ranges as $key => $value){
            if(
    $key<=$code){
                if(
    $ranges[$key][0]>=$code){$two_letter_country_code=$ranges[$key][1];break;}
                }
        }
        if (
    $two_letter_country_code==""){$two_letter_country_code="unkown";}
        return 
    $two_letter_country_code;


  2. #2
    Utente di HTML.it
    Registrato dal
    Aug 2007
    Messaggi
    118
    con il codice procedurale devi dichiarare prima la funzione e DOPO la puoi richiamare

  3. #3
    Potresti essere più preciso nello scrivere l'errore riscontrato?

    Qual'è l'errore preciso?

  4. #4
    Utente bannato L'avatar di Braco
    Registrato dal
    Oct 2005
    Messaggi
    1,697
    Originariamente inviato da lucagiaca
    con il codice procedurale devi dichiarare prima la funzione e DOPO la puoi richiamare
    Il codice lìho preso da qui http://www.phptutorial.info/iptocoun....html#example3 (l'ultimo in fondo) non credo che chi l'ha scritto fosse ubriaco

  5. #5
    Utente bannato L'avatar di Braco
    Registrato dal
    Oct 2005
    Messaggi
    1,697
    Originariamente inviato da Vincent
    Potresti essere più preciso nello scrivere l'errore riscontrato?

    Qual'è l'errore preciso?
    lo puoi vedere qui http://photoman.altervista.org/guestbook/form.php

  6. #6
    Originariamente inviato da lucagiaca
    con il codice procedurale devi dichiarare prima la funzione e DOPO la puoi richiamare
    Hai proprio ragione, la funzione deve essere spostata sopra, prima di essere chiamata. Prova e facci sapere

  7. #7
    Utente bannato L'avatar di Braco
    Registrato dal
    Oct 2005
    Messaggi
    1,697
    Originariamente inviato da Vincent
    Hai proprio ragione, la funzione deve essere spostata sopra, prima di essere chiamata. Prova e facci sapere
    Ho messo cosi, ma forse è peggio http://photoman.altervista.org/guestbook/form.php

    Codice PHP:
    function iptocountry($ip) {
        
    $numbers preg_split"/\./"$ip);
        include(
    "ip_files/".$numbers[0].".php");
        
    $code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]);
        foreach(
    $ranges as $key => $value){
            if(
    $key<=$code){
                if(
    $ranges[$key][0]>=$code){$two_letter_country_code=$ranges[$key][1];break;}
                }
        }
        if (
    $two_letter_country_code==""){$two_letter_country_code="unkown";}
        return 
    $two_letter_country_code;
    }


    $IPaddress=$_SERVER['REMOTE_ADDR']; 
    $two_letter_country_code=iptocountry($IPaddress);
      
    include(
    "ip_files/countries.php");
    $three_letter_country_code=$countries$two_letter_country_code][0];
    $country_name=$countries[$two_letter_country_code][1];

    print 
    "Two letters code: $two_letter_country_code
    "
    ;
    print 
    "Three letters code: $three_letter_country_code
    "
    ;
    print 
    "Country name: $country_name
    "
    ;

    // To display flag
    $file_to_check="flags/$two_letter_country_code.gif";
    if (
    file_exists($file_to_check)){
                    print 
    "<img src=$file_to_check width=20 height=15>
    "
    ;
                    }else{
                    print 
    "<img src=flags/noflag.gif width=20 height=15>
    "
    ;
                    } 

  8. #8
    potresti inviare tutto il codice così si capisce alla linea 97 cosa c'è...?

  9. #9
    Utente di HTML.it
    Registrato dal
    Aug 2007
    Messaggi
    118
    prova a vedere se PRIMA della riga 97 ti sei scordato di mettere il punto e virgola...

  10. #10
    Utente bannato L'avatar di Braco
    Registrato dal
    Oct 2005
    Messaggi
    1,697
    Originariamente inviato da Vincent
    potresti inviare tutto il codice così si capisce alla linea 97 cosa c'è...?
    Questo function iptocountry($ip)

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.