Forum Moderators: coopster

Message Too Old, No Replies

php stream get contents problem

         

xxshadowxx

10:34 pm on Jun 26, 2007 (gmt 0)

10+ Year Member



this shows what the content is, but for some reason, its not writing.

code:

<?php

$file = fopen("/home/gamesjet/public_html/test.txt", "a+");
if ($stream = fopen('http://www.example.net', 'r')) {
// print the first 5 bytes

$contents = stream_get_contents($stream, 100000);
echo $contents;
$post = file_put_contents($file, $contents);

echo $post;

fclose($stream);

?>

mcavic

2:50 am on Jun 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Change file_put_contents to fwrite. File_put_contents does fopen, but you're doing that yourself.

xxshadowxx

3:49 am on Jun 27, 2007 (gmt 0)

10+ Year Member




error:

Parse error: syntax error, unexpected $end in /home/gamesjet/public_html/proxy/index.php on line 15


heres my code:

<?php

$file = fopen("/home/gamesjet/public_html/test.txt", "a+");
if ($stream = fopen('http://www.example.net', 'r')) {
// print the first 5 bytes

$contents = stream_get_contents($stream, 100000);
echo $contents;
$post = fwrite($file, $contents);

echo $post;

fclose($stream);

?>

mcavic

6:52 am on Jun 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You're missing the } before the?>