Page 1 of 1

file_put_contents help

Posted: Thu Oct 04, 2007 2:23 pm
by KinetiX
inside the Ostube script...during the instalation at page 2
i get this error :

Code: Select all

Fatal error: Call to undefined function: file_put_contents() in /home/kinetix/public_html/install/index.php on line 483
I heard that function will not work on PHP 4..wich i have..
tell me how to replace that with something that will work..or if anyone used ostube..how to edit the files manually..Thanks

Posted: Thu Oct 04, 2007 2:26 pm
by John Cartwright
fopen(), fwrite(), and fclose()

You might also be interested in this user comment

Posted: Thu Oct 04, 2007 2:29 pm
by KinetiX
pickle | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hmm...ok so this is my code:
[syntax="php"]// save abs and rel path to /cgi-bin/configs/UberUploads.pm
          $dump = file_get_contents($baseDir . "/cgi-bin/configs/UberUploads.pm"); 
          $str = "my \$base_dir = \"".$_POST['pathABS']."\";" . "\n";
          $str .= "my \$base_url = \"".$_POST['pathREL']."\";" . "\n";
          file_put_contents($baseDir . "/cgi-bin/configs/UberUploads.pm", $str . $dump);
can you write a replacement for me..plsss


pickle | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Oct 04, 2007 2:35 pm
by John Cartwright
No, I already linked to a perfectly suitable replacement.

Posted: Thu Oct 04, 2007 2:38 pm
by pickle
This forum is generally strict but fair - which translates to the fact that you won't ever get anything just written for you. We're here to help you do your work, not do it for you.

Posted: Thu Oct 04, 2007 2:41 pm
by KinetiX
i understand...at least

Code: Select all

$str = "my \$base_dir = \"".$_POST['pathABS']."\";" . "\n";
          $str .= "my \$base_url = \"".$_POST['pathREL']."\";" . "\n";
i`l try to edit the file manually...can you give like a preview of what will it write in the file..maybe i`l understand and edit it manually

Posted: Thu Oct 04, 2007 2:50 pm
by John Cartwright

Code: Select all

echo $str;
..will echo the contents of what you are about to write to the file. You may also be interested in using nl2br(), when viewing the contents, to convert the new lines to line breaks, which will make it more readable.

Posted: Thu Oct 04, 2007 2:54 pm
by pickle

Code: Select all

$str = "my \$base_dir = \"".$_POST['pathABS']."\";" . "\n";
          $str .= "my \$base_url = \"".$_POST['pathREL']."\";" . "\n";
Assuming $_POST['pathABS'] = "/foo", and $_POST['pathREL'] = "/bar", that code will create the string:

Code: Select all

my $base_dir = "/foo"
my $base_url = "/bar"