As if all I fight with the vote from this lesson . Actually there was an assumption that maybe something is not working due to the fact that the lesson is for one version of php, and I have another one. Is it possible?

Actually, if in brief, now just by choosing the option and pressing the vote button, the container contents change, the voting results are shown, but most importantly the voting does not occur (that is, the result and the IP address are not recorded in special files). Description of what is now.

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

myPoll_v_1(); 

Description of the function (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 файлу надо знать куда возвращать результат) }); </script> <div id="pollc"> <!--куда подгружать форму--> </div> <? }else{//если не залогинен выводим пробел echo ' '; } } 

form 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> <h3>Poll</h3> <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 который не работает вообще--> </p> </form> </div> 

Is there such a file flatfile.php for working with files as with a database (if I understood correctly) and there is a strange piece that leads me to certain thoughts 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). Excerpt flatfile.php:

 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 I also asked about this issue.

Please help me figure it out, I’m weak about it because I’m a designer, and I’ve been fighting for 3 days already. And there is no time to study all these technologies. I will give all my points, who will help especially well. )

  • one
    If the solution to this problem is really important for you - write on Skype: alexwindhope <br> There we will figure out, on your fingers to solve such a problem a defective lesson :) - Zowie
  • @alexwindhope please write the answer that you said on Skype. the question must be closed, and the promise to fulfill) - silksofthesoul

3 answers 3

The string forming the id of the category for which the vote was initialized as follows:

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

Accordingly, $ id was always empty and, accordingly, the voices 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']; 

DemoS And the difference? there is a sample code from 2005, the task was for it to work and not for the code to be beautiful :) And for that matter, the best thing would be just if ($ _ GET ['poll'])

Yes, and the problem is generally not in those parts was like ...

  • Thank you very much! - silksofthesoul

blackjack9000, did you fix part of the code in php? When the data is sent 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']) { 

on

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

on the server, set permissions for files so that they are readable and writable and see.

  • rights like exhibited. I didn’t jump out of such errors. There was an error in 128, like a line with the wrong path to the answer file - silksofthesoul

Better still instead

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

Write

 if (isset($_REQUEST['poll'])) { 
  • while everything works, while I will not touch. - silksofthesoul
  • the difference is to reduce the code. array $ _REQUEST, contains $ _GET, $ _POST and $ _COOKIE arrays. - deamondz