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

    Join Date
    Sep 2000
    Posts
    9
    Rep Power
    0
    Is it possible to pipe the output of a script into a file?

    If so, Lets say I had a snip of code that went:

    while(list($id, $array)=each($forums)){
    $forum_name=$array["name"];
    $url="$forum_url/$list_page.$ext?f=$id";
    $sSQL="select count(*) as posts from $array[table_name]";
    $q->query($DB, $sSQL);
    $rec=$q->getrow();
    if(isset($rec)){
    $num_posts=$rec["posts"];
    }
    else{
    $num_posts='0';
    }

    // All the output is right here:
    echo "<a href="$url">$forum_name</a><br> ($num_posts posts)<br><br>n";
    }
    ?>

    And instead of printing the output to a html page I wanted to print the output to a file that could be overwritten again and again,
    How would I do this???

    Thanks,

    Slim
  2. #2
  3. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    6
    Rep Power
    0
    hi try something like this

    instead of echo "<a href="$url">$forum_name</a><br> ($num_posts posts)<br><br>n";

    try

    $line = "<a href="$url">$forum_name</a><br> ($num_posts posts)<br><br>n";


    $fd = fopen($filename , "w");
    fwrite($fd, $line);
    fclose($fd);

    Im not sure what the output will be in the .txt file! So if it prints href="$url" or if it prints href="http://wwwhateverurlisin$url.com"



    ------------------
    Quote the Dokus:"NeverMore!"
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    9
    Rep Power
    0
    Thanks! I'll Give it a go..

    Slim

Similar Threads

  1. Oracle sqlplus query output into file
    By phil_CH in forum Oracle Development
    Replies: 6
    Last Post: January 27th, 2009, 12:28 PM
  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. Cron Job output to system output or a file
    By sathi in forum UNIX Help
    Replies: 3
    Last Post: February 4th, 2004, 08:25 AM

IMN logo majestic logo threadwatch logo seochat tools logo