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

    Join Date
    Jan 2000
    Location
    Netherlands
    Posts
    32
    Rep Power
    15
    Hi,

    Trying to make a kind of guestbook using an ascii-file, I encountered a problem.

    For showing the questbook these steps are followed:
    1. read guestbook items, line by line
    and check if the item is expired.
    if expired then updateNeeded = true;
    if !expired then add it to the array of all guestbook items.

    2. if updateNeeded then write guestbook-array to ascci-file first.
    if !updateNeeded then do nothing.

    3. write array to screen.

    --------
    Loading the script-file the first time everything went well:
    any expired items were left out first and
    ascii-file was updated if needed,
    !expired items were shown, nicely.

    So far so good.

    But when I hit the refresh button of the browser, updateNeeded seems to be still true and the array empty, which leaves me with an empty(! the empty array must be written to the file) ascii-file and with no more guestbook items left also an empty screen.

    So I am open to suggestions.

    Thanks,

    Richard


    // begin MainProgram

    $updateNeeded = FALSE;
    make_arrays();
    if ($updateNeeded == TRUE) {
    echo "updating...";
    write_lines("data/ascii-file.csv", $clipboard_id,8);
    $updateNeeded = FALSE;
    }
    // Okay, write it to the screen
    for ($row=1; $row<=count($clipboard_id[1]); $row++) {
    write_tabel(change_tbbg(),$clipboard_id,$row);
    }

    // end Program
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    <<
    make_arrays();
    >>


    Can you post that functions also..so we can tell you what is going wrong...



    ------------------
    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
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Location
    Netherlands
    Posts
    32
    Rep Power
    15
    Okay SR, here it comes:

    function make_arrays() {
    // colomns == main-array, row == subarrays
    function make_array($fileNr,$fileName,$colums,$intColumn) {
    global $updateNeeded;

    $row = 1;
    $fp = fopen($fileName,"r");
    while ($data = fgetcsv($fp,1000, ";")) {
    for ($i=1; $i<=$columns; $i++) {
    $fileArray_tmp[$i][$row] = $data[$i-1];
    }
    // settype($fileArray[$intColumn][$row], "integer");
    if (!date_ok($fileArray_tmp,$row)) {
    $updateNeeded = TRUE;
    }
    else {
    for ($i=1; $i<=$columns; $i++) {
    $fileArray[$i][$row] = $fileArray_tmp[$i][$row];
    }
    $row++;
    }
    }
    fclose($fp);
    if ($fileNr == "1") {
    global $clipboard_id;
    $clipboard_id = $fileArray;
    }
    }

    $path = get_path() . "leden/clipboard/data/";
    make_array("1",$path . "clipboard.csv",8,7);
    }


    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by Shiju Rajan:

    <<
    make_arrays();
    >>


    Can you post that functions also..so we can tell you what is going wrong...



    [/quote]

    ps Nice signature!
  6. #4
  7. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    <<
    function make_arrays() {
    // colomns == main-array, row == subarrays
    >>

    Why this two functions?
    make_array and make_arrays...

    the code looks ok...i'm not seeing any problem in that....


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


    "The fear of the LORD is the beginning of knowledge..."

    [This message has been edited by Shiju Rajan (edited October 11, 2000).]
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Location
    Netherlands
    Posts
    32
    Rep Power
    15
    How can one make sure that variable $updateNeeded becomes false after hitting refresh?

    Or is there a workaround?

    Please, who can help me out?

    Does anybody have a suggestion, cause I am stuck...

    [This message has been edited by Richard Vos (edited October 16, 2000).]

Similar Threads

  1. refresh on browser back button
    By Daytona955i in forum Perl Programming
    Replies: 2
    Last Post: February 12th, 2004, 10:00 AM
  2. Pointer problem in opening a file
    By LAKI in forum C Programming
    Replies: 13
    Last Post: February 11th, 2004, 08:27 AM
  3. Pointer problems opening file *formatted*
    By LAKI in forum C Programming
    Replies: 4
    Last Post: February 11th, 2004, 06:06 AM
  4. PHP file upload script trouble
    By casbboy in forum PHP Development
    Replies: 9
    Last Post: February 5th, 2004, 07:42 PM
  5. load external html file in an empty movieclip
    By musher5 in forum Flash Help
    Replies: 2
    Last Post: January 29th, 2004, 12:00 AM

IMN logo majestic logo threadwatch logo seochat tools logo