Jump to content

Implimenting code into fwrite correctly


Freedom-n-Democrazy

Recommended Posts

Hmm one last thought. Do you have the correct permissions set on the directory the text file is in?

 

Try:

chmod 777 /whatever/directory/your/in 

 

Also chmod 777 the actual file, but directory if PHP is generating the file for you.

 

Also in your above code you never gave the correct arguments :P 

You gave

file_put_contents($data, $data)

instead of

file_put_contents($file, $data)

 

If your going to use file_put_contents I would also suggest using LOCK_EX.

 

file_put_contents($file, $data, LOCK_EX)

 

Hope this helps :)

 

--LiquidFusi0n

Link to comment
Share on other sites

Well I can now 100% say it's not a PHP bug as I have just written a working code.

 

   1 <html>
  2 <body>
  3 
  4 <form method="POST" action="test.php">
  5 Feedback: <input type="text" name="feedback">
  6 <input type="submit" value="Feedback" name="submit">
  7 
  8 <?php
  9 
10 if(isset($_POST['submit']) && isset($_POST['feedback'])){
11         $file = "test.txt";
12         $data = $_POST['feedback'];
13         file_put_contents ($file, $data);
14         echo "Done";
15 }
16 
17 ?>
18 
19 </body>
20 </html>

 

So now we know it is a machine/code specific problem hmmmmm

 

--LiquidFusi0n

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.