file_put_contents help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
KinetiX
Forum Newbie
Posts: 6
Joined: Thu Oct 04, 2007 2:18 pm

file_put_contents help

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

fopen(), fwrite(), and fclose()

You might also be interested in this user comment
KinetiX
Forum Newbie
Posts: 6
Joined: Thu Oct 04, 2007 2:18 pm

Post 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]
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

No, I already linked to a perfectly suitable replacement.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
KinetiX
Forum Newbie
Posts: 6
Joined: Thu Oct 04, 2007 2:18 pm

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
Last edited by John Cartwright on Thu Oct 04, 2007 3:20 pm, edited 1 time in total.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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"
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply