Why is this part of the code not working?

I’m struggling with voting with of this tutorial. Actually, there was an assumption that, perhaps, something does not work due to the fact that the lesson is designed for one version of php, and I have another one. Is this possible?

Actually, in short, now just when you select an option and click on the vote button, the contents of the container change, the voting results are displayed, but most importantly, voting does not take place(that is, the result and IP address are not recorded to special files). Description of what is now.

In one of the places I need, I call the function:


Function description (in one of the template files):

function myPoll_v_1(){
    global $user_ID; if ($user_ID) {// ,  
<script type="text/javascript">
$(document).ready(function () { //    
    $('#pollc').load('p/my_poll/xxx.html'); // (     php      )
<div id="pollc">
<!--  -->
    echo  ' ';

shape file(xxx.html):

<script src="/p/my_poll/poll.js" type="text/javascript" charset="utf-8"><!--   ,       --></script>
<div id="poll-container">
<div class="trace22"><!----></div>
<form id='poll' action="/p/my_poll/poll.php" method="post" accept-charset="utf-8">
<p>Pick your favorite Javascript framework:</p><p>
<input type="radio" name="poll" value="opt1" id="opt1" /><label for='opt1'>&nbsp;jQuery</label><br />
<input type="radio" name="poll" value="opt2" id="opt2" /><label for='opt2'>&nbsp;Ext JS</label><br />
<input type="radio" name="poll" value="opt3" id="opt3" /><label for='opt3'>&nbsp;Dojo</label><br />
<input type="radio" name="poll" value="opt4" id="opt4" /><label for='opt4'>&nbsp;Prototype</label><br />
<input type="radio" name="poll" value="opt5" id="opt5" /><label for='opt5'>&nbsp;YUI</label><br />
<input type="radio" name="poll" value="opt6" id="opt6" /><label for='opt6'>&nbsp;mootools</label><br /><br />
<a onclick="return false;">Voooote &rarr;</a><br><!--     input type submit    -->

There is such a flatfile.php file for working with files as with a database (if I understand correctly) and there is a strange piece there that makes me think about the incompatibility of this file with my version of php, it is with a comment in a foreign language (and I don’t know Russian well, lol). Flatfile.php excerpt:

function resolveJoins(&$tables)
    foreach ($tables as $tablename => $discard) {
        // PHP4 compatible: can't do :  foreach ($tables as $tablename => &$tabledef)
        // and strangely, if we do 
        // foreach ($tables as $tablename => &$tabledef)
        //     $tabledef =& $tables[$tablename];
        // then we get bugs
        $tabledef =& $tables[$tablename];
        foreach ($tabledef as $colname => $discard) {
            $coldef =& $tabledef[$colname]; // PHP4 compatible
            if (is_a($coldef, 'JoinColumn') or is_subclass_of($coldef, 'JoinColumn')){
                TableUtils::resolveColumnJoin($coldef, $tables);

Here hereI also asked about this problem.

Please help me figure it out, I’m not very good at this, as a designer, and I’ve been struggling for like 3 days now. And there is no time to study all these technologies. I will give all my points to whoever is especially good at helping. )

Answer 1, authority 100%

The string forming the id of the category voted for was initialized like this:

$id = $_GET['vote'] || $_POST['vote'];

Accordingly, the $id was always empty and, accordingly, the votes did not change, in general, the problem was especially with the || operator, the line above had to be replaced with:

$id = $_GET['vote'] or $_POST['vote'];

DemoSWhat’s the difference? there is a sample code of 2005, the task was to make it work and not to make the code beautiful 🙂 And for that matter, it would be best to just

Yes, and the problem was not in those parts at all…

Answer 2, authority 25%

blackjack9000, did you fix part of the code in php? When passing data to the demo/golosovanie/poll.php?vote=1 handler, I got php errors

Notice: Undefined index: poll in E:\demo\golosovanie\poll.php on line 24

I fixed this line in poll.php

if ($_GET['poll'] || $_POST['poll']) {


if (isset($_GET['poll']) || isset($_POST['poll'])) {

on the server, set the permissions for the files so that they are readable and writeable and look.

Answer 3, authority 25%

Better yet

if (isset($_GET['poll']) || isset($_POST['poll'])) {


if (isset($_REQUEST['poll'])) {