FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Failed to write to a text file (text file is RW)
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Failed to write to a text file (text file is RW) [message #171414] Sun, 02 January 2011 20:19 Go to previous message
justaguy is currently offline  justaguy
Messages: 16
Registered: December 2010
Karma:
Junior Member
Hi,

I dig up the following script. Added a simple HTML file with a form
field named "vote" and have it send to the following php script.
However, it failed to write to the poll_result.txt file. Why?

Thanks as usual.

<?php
$vote = $_REQUEST['vote'];

//get content of textfile
$filename = "poll_result.txt";
$content = file($filename);

//put content in array
$array = explode("||", $content[0]);
$yes = $array[0];
$no = $array[1];

if ($vote == 1)
{
$yes = $yes + 1;
}
if ($vote == 0)
{
$no = $no + 1;
}


// debug
echo $yes;
echo $no;

// output and comments
/*
Seed poll_result.txt to read 0||0

It's always 10 even though I checked the YES option several times
obviously it failed to write to the poll_result.txt file.

Checked the poll_result.txt, it's 0||0

*/


//insert votes to txt file
$insertvote = $yes."||".$no;
$fp = fopen($filename,"w");
fputs($fp,$insertvote);
fclose($fp);
?>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Print PHP Manual
Next Topic: Fetching an external web page
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 07:45:08 GMT 2024

Total time taken to generate the page: 0.04255 seconds