#1
  1. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    6
    Rep Power
    0
    the following code has an input from http://www.mydomain.com/index.phtml?id=myname
    the file in.txt has the contains the following www.mydomain.com:myname:5 (5 is the hits i send through the url, its a referrer script)
    this is what i have:

    $name = $id;
    $filename = "in.txt";


    $hits = file($filename); //* $hits includes the whole text

    $totaal = count($hits);

    for($i=0 ; $i < $totaal ; $i++)
    {

    $line = $hits[$i]; //* $line includes one line
    $instukjes = split(":" , $line); //* $instukjes[0] include the first string
    //* untill ":" is reached


    if($instukjes[1] == $name)
    {

    $instukjes[2] = $instukjes[2] + 1;
    echo "$instukjes[2]";
    $line = $instukjes[0] . ":" . $instukjes[1] . ":" . $instukjes[2] . "n";
    $hits[$i] = $hits[$i], $line;
    echo "$hits[$i]<br>";
    echo "$hits <br>";

    }


    }
    $fd = fopen($filename , "w");
    fwrite($fd, $hits, strlen($hits));
    fclose($fd);

    now if i do a echo on $hits it returns ARRAY
    and it writes ARRAY in the file im trying to write to!

    how can is solve this problem?


    ------------------
    Quote the Dokus:"NeverMore!"
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    Write the array values to the file using a loop

    $fd = fopen($filename , "w");

    for($b=0;$b<count($hits);$b++){
    fwrite($fd, $hits[$b]);
    }

    fclose($fd);

    ---


    ------------------
    SR -
    webshiju.com
    www.jobxyz.com-IT Career Portal
    ezipindia.com--WebStudio


    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    6
    Rep Power
    0
    Yes this works!!!

    whohooo your da man, Shiju Rajan!!

    thnx :-)



    ------------------
    Quote the Dokus:"NeverMore!"

Similar Threads

  1. writing a file to a ftp server
    By buddinghere in forum FTP Help
    Replies: 1
    Last Post: February 12th, 2004, 11:36 AM
  2. Pointer problem in opening a file
    By LAKI in forum C Programming
    Replies: 13
    Last Post: February 11th, 2004, 09:27 AM
  3. Replies: 1
    Last Post: February 8th, 2004, 02:59 PM
  4. Upload file name problem
    By clio in forum PHP Development
    Replies: 1
    Last Post: February 6th, 2004, 07:19 AM
  5. Problem with opening a file
    By Psantiago in forum C Programming
    Replies: 3
    Last Post: February 3rd, 2004, 08:31 PM

IMN logo majestic logo threadwatch logo seochat tools logo