Rishele Posted September 15, 2007 Share Posted September 15, 2007 I'm A NOOB at PHP and I'm very confused! I'm trying to post a VOTING SYSTEM on my webstie. I finally found a tutorial that told me how to install it. I did it step by step but when I tried to view the page, this error message came up: Parse error: parse error, unexpected T_OBJECT_OPERATOR in /home/content/s/i/s/sisqo/html/voting/savevote.php on line 34 I went to line 34 but I don't see anything wrong with it. Can somebody please HELP ME! ??? ??? ??? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted September 15, 2007 Share Posted September 15, 2007 Post line 30 - 38 here from savevote.php. Looks like something is not quite right with code. Quote Link to comment Share on other sites More sharing options...
Rishele Posted September 15, 2007 Author Share Posted September 15, 2007 //Loop through the addresses nodes and see if the person has voted before foreach( $addresses as $address ) { $lastvisits = $address->getElementsByTagName("lastvisit"); $lastvisit = $lastvisits->item(0)->nodeValue; $ips = $address->getElementsByTagName("ip"); $ip = $ips->item(0)->nodeValue; if ($ip == $domain) ____BELOW IS LINE 39-UNTIL____ { $pFound = true; if ($lastvisit == $today) $pVoted = true; else { $lastvisits->item(0)->nodeValue = $today; $doc->save("xml/addresses.xml"); } break; } else continue; } if ($pVoted == true) //Already voted { echo "<tr><td colspan=\"3\" class=\"message\">Sorry, you already voted once today.</td></tr>"; } else //Update the XML files { if ($pFound == false) //Add new node for IP and date to addresses.xml { echo "<tr><td colspan=\"3\" class=\"message\">Thanks for voting for $votefor! You can vote again tomorrow.</td></tr>"; $newAddy = $doc->getElementsByTagName('addresses')->item(0); $newAddressElement = $doc->createElement('address'); $newLastVisitElement = $doc->createElement('lastvisit'); $newAddressElement->appendChild($newLastVisitElement); $newIPElement = $doc->createElement('ip'); $newAddressElement->appendChild($newIPElement); $dayvalue = $doc->createTextNode($today); $dayvalue = $newLastVisitElement->appendChild($dayvalue); $ipvalue = $doc->createTextNode($domain); $ipvalue = $newIPElement->appendChild($ipvalue); $newAddy->appendChild($newAddressElement); $doc->save("xml/addresses.xml"); } else { echo "<tr><td colspan=\"3\" class=\"message\">Thanks for voting for $votefor!</td></tr>"; } // Update the vote $doc = new DOMDocument(); $doc->load("xml/results.xml"); $pollitems = $doc->getElementsByTagName("pollitem"); foreach( $pollitems as $pollitem ) { $entries = $pollitem->getElementsByTagName("entryname"); $entry = $entries->item(0)->nodeValue; if ($entry == $votefor) { $votes = $pollitem->getElementsByTagName("votes"); $count = $votes->item(0)->nodeValue; $votes->item(0)->nodeValue = $count + 1; break; } } $doc->save("xml/results.xml"); } } else { echo "<tr><td colspan=\"3\" class=\"message\">Poll Results</td></tr>"; } // Get max vote count $doc = new DOMDocument(); $doc->load("xml/results.xml"); $maxvotes = 0; $pollitems = $doc->getElementsByTagName("pollitem"); foreach( $pollitems as $pollitem ) { $votes = $pollitem->getElementsByTagName("votes"); $vote = $votes->item(0)->nodeValue; $maxvotes = $maxvotes + $vote; } // Generate the results table $doc = new DOMDocument(); $doc->load("xml/results.xml"); $pollitems = $doc->getElementsByTagName("pollitem"); foreach( $pollitems as $pollitem ) { $entries = $pollitem->getElementsByTagName("entryname"); $entry = $entries->item(0)->nodeValue; $votes = $pollitem->getElementsByTagName("votes"); $vote = $votes->item(0)->nodeValue; $tempWidth = $vote / $maxvotes; $tempWidth = 300 * $tempWidth; $votepct = round(($vote / $maxvotes) * 100); echo "<tr><td width=\"30%\" class=\"polls\">$entry</td>"; echo "<td width=\"50%\" class=\"resultbar\"><div class=\"bar\" style=\"background-color: "; getRandomColor(); echo "; width: $tempWidth px;\">$votepct%</div></td><td width=\"20%\">($vote votes)</td></tr>"; } echo "<tr><td class=\"total\" colspan=\"3\">$maxvotes people have voted in this poll.</td>"; echo "</table>"; ?> Quote Link to comment Share on other sites More sharing options...
Rishele Posted September 16, 2007 Author Share Posted September 16, 2007 anybody have any idea what's wrong? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted September 16, 2007 Share Posted September 16, 2007 Looks like that code is using object chaining. Object chaining can only be used with PHP5. What version of PHP are you running? Quote Link to comment Share on other sites More sharing options...
Rishele Posted September 17, 2007 Author Share Posted September 17, 2007 I have no idea which version I'm using. How can I tell? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted September 17, 2007 Share Posted September 17, 2007 Run either the phpinfo() function or echo phpversion() to see which version of PHP is installed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.