I would like to use this poll, but it doesn’t really work. It seems to in the demo, but the count doesn’t work right and is stuck at 53. I messed around a little and have no luck. It seems to be the PHP and not the jQuery.
[Sun Oct 26 12:34:16 2008] [error] [client xx.xxx.xx.xxx] PHP Warning:
fopen(data/essaycontest_ips.txt.lock) [function.fopen]: failed to open stream:
Permission denied in /var/www/html/scripts/poll/flatfile.php on line 181, referer:
http://www.example.com/scripts/poll/poll.html
I don’t know PHP at all, but poll.js is supposed to write to two files: votes.txt and ips.txt. It does write to ips.txt which has about 10 IP addresses in it right now. The votes.txt file is empty. I’m guessing the PHP that is supposed to increment the vote is wrong or broken and the tutorial writer never checked it.
I don’t get any error messages ever. it just shows
Poll Results
Total Votes: 0
If I had left the default votes.txt file it would show 53 votes like everyone else commenting on the tutorial has - apparently a starter number.
It seems like a simple problem, but lots of people who tried the tut are stumped. :injured:
Can you please package together the files that you have that relate to this voting poll, and attach them to a message so that we can dig in to them and sort this out.
Okay, it seems that there are many issues with the php code.
Here’s the list of errors and warnings that I get when running it as a non-scripted submit.
Notice: Use of undefined constant INT_COL - assumed 'INT_COL' in /home/amemoryt/public_html/beta/test/sitepoint/poll/flatfile.php on line 47
Notice: Use of undefined constant DATE_COL - assumed 'DATE_COL' in /home/amemoryt/public_html/beta/test/sitepoint/poll/flatfile.php on line 48
Notice: Use of undefined constant STRING_COL - assumed 'STRING_COL' in /home/amemoryt/public_html/beta/test/sitepoint/poll/flatfile.php on line 49
Notice: Use of undefined constant FLOAT_COL - assumed 'FLOAT_COL' in /home/amemoryt/public_html/beta/test/sitepoint/poll/flatfile.php on line 50
Notice: Undefined index: poll in /home/amemoryt/public_html/beta/test/sitepoint/poll/poll.php on line 23
Notice: Undefined index: poll in /home/amemoryt/public_html/beta/test/sitepoint/poll/poll.php on line 71
Warning: fopen(data/ips.txt.lock) [function.fopen]: failed to open stream: Permission denied in /home/amemoryt/public_html/beta/test/sitepoint/poll/flatfile.php on line 183
Warning: flock() expects parameter 1 to be resource, boolean given in /home/amemoryt/public_html/beta/test/sitepoint/poll/flatfile.php on line 184
Warning: fwrite(): supplied argument is not a valid stream resource in /home/amemoryt/public_html/beta/test/sitepoint/poll/flatfile.php on line 355
Warning: fclose(): supplied argument is not a valid stream resource in /home/amemoryt/public_html/beta/test/sitepoint/poll/flatfile.php on line 356
Warning: flock() expects parameter 1 to be resource, boolean given in /home/amemoryt/public_html/beta/test/sitepoint/poll/flatfile.php on line 196
Warning: Cannot modify header information - headers already sent by (output started at /home/amemoryt/public_html/beta/test/sitepoint/poll/flatfile.php:47) in /home/amemoryt/public_html/beta/test/sitepoint/poll/poll.php on line 94
Warning: fopen(data/votes.txt.lock) [function.fopen]: failed to open stream: Permission denied in /home/amemoryt/public_html/beta/test/sitepoint/poll/flatfile.php on line 183
Warning: flock() expects parameter 1 to be resource, boolean given in /home/amemoryt/public_html/beta/test/sitepoint/poll/flatfile.php on line 184
Warning: fwrite(): supplied argument is not a valid stream resource in /home/amemoryt/public_html/beta/test/sitepoint/poll/flatfile.php on line 355
Warning: fclose(): supplied argument is not a valid stream resource in /home/amemoryt/public_html/beta/test/sitepoint/poll/flatfile.php on line 356
Warning: flock() expects parameter 1 to be resource, boolean given in /home/amemoryt/public_html/beta/test/sitepoint/poll/flatfile.php on line 196
Warning: file_get_contents(index.html) [function.file-get-contents]: failed to open stream: No such file or directory in /home/amemoryt/public_html/beta/test/sitepoint/poll/poll.php on line 127
Notice: Undefined variable: total_votes in /home/amemoryt/public_html/beta/test/sitepoint/poll/poll.php on line 135
This resulted in the following permissions change to the data files
-rw-rw-rw- 1 amemoryt amemoryt 0 Feb 8 13:53 votes.txt
-rw-rw-rw- 1 amemoryt amemoryt 0 Feb 8 14:34 ips.txt
After running the page now, the data files update as per normal
-rw-rw-rw- 1 amemoryt amemoryt 11 Feb 8 16:40 votes.txt
-rw-rw-rw- 1 amemoryt amemoryt 15 Feb 8 16:40 ips.txt
So now that it works, does anyone know of a better solution regarding their permissions? Would setting them back to 644 and changing their user to nobody be a better alternative?