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

    Join Date
    Jul 2000
    Posts
    2
    Rep Power
    0
    When I do :
    $f=file(PATH . "vote.txt");
    if($option=="not good") $f[0]+=1;
    if($opcao=="good") $f[1]+=1;
    if($opcao=="very good") $f[2]+=1;
    $fw=fopen(PATH . "vote.txt","w");
    foreach($f as $value){
    fputs($fw,strval($value)."n");
    }
    fclose($fw);

    And the file vote.txt looks like this:

    0

    1
    3

    Why?
    Shouldn't be:
    0
    1
    3
    ?????

    Please, help me

    PS: Sorry my bad english


    ------------------
    {C00L|Z3R0} on irc.ptnet.org
  2. #2
  3. No Profile Picture
    Robert_J_Sherman
    Guest
    Devshed Newbie (0 - 499 posts)
    The only thing I can suggest is that one of those values being written is actually null.

    In short, you get an empty line, because there are 4 lines, one is empty.

    I'd say look through your data, find out where or why a value is empty.

    It would most likely be the cause, since you have a "line feed" added to the value.

    ------------------
    SnR Graphics,
    Low Cost Hosting and Web Development.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    2
    Rep Power
    0
    I have found the solution (not the problem)

    $f=file(PATH . "vote.txt");
    $f[0]+=0;
    $f[1]+=0;
    $f[2]+=0;

    if($option=="not good") $f[0]+=1;
    if($opcao=="good") $f[1]+=1;
    if($opcao=="very good") $f[2]+=1;
    $fw=fopen(PATH . "vote.txt","w");
    foreach($f as $value){
    fputs($fw,strval($value)."n");
    }
    fclose($fw);

    I don't why this works and the other not...

    PS: Sorry my bad english

Similar Threads

  1. Very strange DNS error
    By mjs3434 in forum DNS
    Replies: 11
    Last Post: December 24th, 2006, 02:16 AM
  2. I'll give you free hosting..
    By niteryder in forum Free Web Hosting
    Replies: 4
    Last Post: February 14th, 2004, 03:14 AM
  3. how shall i give a folder a unique identification?
    By j0sh in forum PHP Development
    Replies: 2
    Last Post: January 14th, 2004, 04:55 PM
  4. Replies: 4
    Last Post: January 12th, 2004, 01:03 AM
  5. give a session variable an array value
    By macintoshp in forum ASP Programming
    Replies: 1
    Last Post: December 15th, 2003, 03:40 AM

IMN logo majestic logo threadwatch logo seochat tools logo