Re: [PHP] fputs/fgets working irregularly

2002-06-09 Thread Tom Rogers

Hi
Why not just do it in one call?

$fp = fopen("data/news.txt","w");
  $np = fputs($fp,$pr.$ag);
  fclose($fp);


Tom


At 04:17 AM 10/06/2002, Kris wrote:
>Hi all,
>
>I'm having some trouble getting my basic news script to work. Here is the
>code:
>
>  $fp = fopen("data/prev.txt","r");
>  while (!feof ($fp)) {
>  $pr = fgets($fp, 4096);
>  }
>  fclose($fp);
>
>  $fp = fopen("data/news.txt","r");
>  while (!feof ($fp)) {
>  $ag = fgets($fp, 4096);
>  }
>  fclose($fp);
>
>  $fp = fopen("data/news.txt","w");
>  $np = fputs($fp,$pr);
>  fclose($fp);
>
>  $fp = fopen("data/news.txt","a");
>  $ng = fputs($fp,$ag);
>  fclose($fp);
>
>The news.txt does not append what is stored in $pr for some reason. I can't
>put my finger on what the problem is, the file is chmod correctly as well.
>Can anyone help?
>
>Thanks,
>Kris
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] fputs/fgets working irregularly

2002-06-09 Thread Kris

Hi all,

I'm having some trouble getting my basic news script to work. Here is the
code:

 $fp = fopen("data/prev.txt","r");
 while (!feof ($fp)) {
 $pr = fgets($fp, 4096);
 }
 fclose($fp);

 $fp = fopen("data/news.txt","r");
 while (!feof ($fp)) {
 $ag = fgets($fp, 4096);
 }
 fclose($fp);

 $fp = fopen("data/news.txt","w");
 $np = fputs($fp,$pr);
 fclose($fp);

 $fp = fopen("data/news.txt","a");
 $ng = fputs($fp,$ag);
 fclose($fp);

The news.txt does not append what is stored in $pr for some reason. I can't
put my finger on what the problem is, the file is chmod correctly as well.
Can anyone help?

Thanks,
Kris



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php