Results 1 to 11 of 11

Thread: Use enter?

  1. #1

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Use enter?

    Id like to explode() by enter..but im not sure how

    can i use chr() in php?

  2. #2
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770

    Re: Use enter?

    yes, chr() is a php function. It takes an ascii code and converts it to a character.

  3. #3

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Use enter?

    so for enter id use it like this?
    $entry = explode(chr("13"),$contents)

    or what?

  4. #4

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Use enter?

    and would this script work:
    PHP Code:
    <html>
    <
    form>
    <
    body>
    <
    php?
        
    $ip =  $_SERVER['REMOTE_ADDR'];
        
    $handle fopen("IPTimes.txt" "r+") or die("Err1");
        
    $contents = @fread($handle,filesize("IPTimes.txt")) or die("Err2");
            If(
    Strpos($contents,$ip)===False){
              
    fwrite($handle,$contents.chr(13+10).":".$ip."1");
                    
    $NumVisits 1
            
    }Else{
                
    $entry explode(chr(13 10),$contents);
                    
    $Number 0;
                    foreach(
    $entry as $x){
                           
    $Number2 explode($entry['$Number'];
                           
    $Number2['1']++;
                           
    $NumVisits $Number2['1'];
                        
    $Number++;
                    }
            }
            Echo 
    $ip."</br>".$NumVisits
    ?>
    </body>
    </form>
    </html> 

  5. #5
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770

    Re: Use enter?

    i think
    Code:
     $entry = explode(chr(13 + 10),$contents);
    should be
    Code:
     $entry = explode(chr(13) . chr(10),$contents);
    the rest of your code looks good

  6. #6

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Use enter?

    if thats all...that sure would be a first

  7. #7
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Use enter?

    In PHP you can use the escape sequence \r\n for a carridge return and linefeed:
    PHP Code:
        $entry explode("\r\n",$contents); 
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  8. #8

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Use enter?

    thanks guys. On my echo statement, im getting this:

    ".$NumVisits."Visits" ?>

    Instead it should be like
    127.0.0.1 1 Visits

    What did i do wrong?

  9. #9

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Use enter?

    wow i figured it out
    <php?
    <?php


    But i continue to get errors.
    PHP Code:
    <html>
    <form>
    <body>
    <?php
        $ip 
    =  $_SERVER['REMOTE_ADDR'];
        
    $handle fopen("IPTimes.txt""r+") or die("Err1");
        
    $contents = @fread($handle,filesize("IPTimes.txt")) or die("Err2");
            If(
    Strpos($contents,$ip)===False){
              
    fwrite($handle,$contents."\r\n".":".$ip."1");
                    
    $NumVisits 1;
            }Else{
                 
    $entry explode("\r\n",$contents);
                    
    $Number 0;
                    foreach(
    $entry as $x){
                                If(
    strpos($entry['$Number'],$ip)){
                           
    $Number2 explode(":",$entry['$Number'];
                           
    $Number2['1']++;
                           
    $NumVisits $Number2['1'];
                                }
                           
    $Number++;
                    }
            }
            Echo 
    "$ip </br> $NumVisits Visits"
            
    fclose($handle)
    ?>
    </body>
    </form>
    </html>
    $Number2 = explode(":",$entry['$Number'];

  10. #10
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Use enter?

    This is an error you make a lot, you need to ensure you close your brackets for the explode function.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  11. #11

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Use enter?

    Man. Im getting the eclipse IDE right now to fix that. Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width