Jump to content

[SOLVED] generate .conf file using php and mysql


srinivas6203

Recommended Posts

Woot wildteen88, nice one, never seen file_put_contents() before since it's somewhat new.

I've just been using fopen/fwrite/fclose which by the looks of things the OP will still need to use if they are still using PHP4

 

He is right though, just use file_put_contents() and instead of echo to the page, add everything into a variable and use that function. Make sure you add "\n" to the end of lines in any strings that need them.

Link to comment
Share on other sites

I tried by the using of following script. But i got errors.

 

$path="var/www/files/";

$file=$path."test_file.txt";

$fp=fopen($file,"w");

//echo file_put_contents($file,"Hello World. Testing!");

fwrite($fp, 'sample data');

fclose($fp);

 

I got following errors:

 

Warning: fopen(var/www/files/test_file.txt) [function.fopen]: failed to open stream: No such file or directory in /var/www/admin/conf_changes.php on line 11

 

Warning: fwrite(): supplied argument is not a valid stream resource in /var/www/admin/conf_changes.php on line 13

 

Warning: fclose(): supplied argument is not a valid stream resource in /var/www/admin/conf_changes.php on line 14

 

Please help me out.

Link to comment
Share on other sites

Problem was solved by using following script. Thanx for every cooperation.

 

$dh="/var/www/admin/";

`sudo chmod 777 $dh`;

$file="test.txt";

$fullpath=$dh.$file;

`sudo chmod 777 $fullpath`;

$create_file=fopen($fullpath,"w+");

$stringData = 'sample';

fwrite($create_file, $stringData);

fclose($create_file);

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.