If you are not registered or logged in, you may still use these forums but with limited features. Show recent topics
  [Search] Search   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [FAQ]  FAQ 
[Register] Register / 
[Login] Login 
*.pl file write error.  XML
Forum Index » Support Forum
Author Message
Anonymous



I use a .pl file for a poll on my website, but all at once it doen't work anymore. You can find the code at the end of this message. Anyways, the problem is that de pl file doesn't write data in a txt file, specified for the poll. Can anyone find what the problem is so I can use my poll again, because I cant.

Greetz.

### BEGIN OF THE CODE ###



#!/usr/local/bin/perl

use CGI;
$q = new CGI;
$keuze = $q->param('plannen');


print "Content-type:text/html\n\n";
print "<html><head>";
print "<link href=\"../css/hodena.css\" type=\"text/css\" rel=\"StyleSheet\">";
print "</head>";


##### resultaten ophalen #####
open (INPUTFILE, "d:/inetpub/clubroot/hodena/js/finalepoll.txt");
$plan1 = <INPUTFILE>;($plan1) = ($plan1 =~ /(.*)\W+/);
$vote1 = <INPUTFILE>;($vote1) = ($vote1 =~ /(.*)\W+/);
$plan2 = <INPUTFILE>;($plan2) = ($plan2 =~ /(.*)\W+/);
$vote2 = <INPUTFILE>;($vote2) = ($vote2 =~ /(.*)\W+/);
$plan3 = <INPUTFILE>;($plan3) = ($plan3 =~ /(.*)\W+/);
$vote3 = <INPUTFILE>;($vote3) = ($vote3 =~ /(.*)\W+/);
$plan4 = <INPUTFILE>;($plan4) = ($plan4 =~ /(.*)\W+/);
$vote4 = <INPUTFILE>;($vote4) = ($vote4 =~ /(.*)\W+/);
$plan5 = <INPUTFILE>;($plan5) = ($plan5 =~ /(.*)\W+/);
$vote5 = <INPUTFILE>;($vote5) = ($vote5 =~ /(.*)\W+/);
close INPUTFILE;

### resultaten aanpassen met nieuwe vote ###
if ( $keuze eq $plan1 ) { $vote1++; }
if ( $keuze eq $plan2 ) { $vote2++; }
if ( $keuze eq $plan3 ) { $vote3++; }
if ( $keuze eq $plan4 ) { $vote4++; }
if ( $keuze eq $plan5 ) { $vote5++; }

### resultaten wegschrijven ###
open (DATAFILE, "</d:/inetpub/clubroot/hodena/js/finalepoll.txt");
print DATAFILE $plan1; print DATAFILE "\n";
print DATAFILE $vote1; print DATAFILE "\n";
print DATAFILE $plan2; print DATAFILE "\n";
print DATAFILE $vote2; print DATAFILE "\n";
print DATAFILE $plan3; print DATAFILE "\n";
print DATAFILE $vote3; print DATAFILE "\n";
print DATAFILE $plan4; print DATAFILE "\n";
print DATAFILE $vote4; print DATAFILE "\n";
print DATAFILE $plan5; print DATAFILE "\n";
print DATAFILE $vote5; print DATAFILE "\n";
close DATAFILE;



### screenoutput berekenen ###
$total = $vote1 + $vote2 + $vote3 + $vote4 + $vote5;

$percent1 = ((int(($vote1 / $total) * 1000)) / 10);
$percent1 = substr($percent1,0,4);
if ($vote1 < 1) { $percent1 = "0";}
$width1 = int($percent1 * 1);
if ($vote1 < 1) { $width1 = 2;}
$percent1 = "$percent1%";
$image_percent1 = "<IMG SRC=\"/hodena/figuren/bar.jpg\" Height=\"10\" Width=\"$width1\">";

$percent2 = ((int(($vote2 / $total) * 1000)) / 10);
$percent2 = substr($percent2,0,4);
if ($vote2 < 1) { $percent2 = "0";}
$width2 = int($percent2 * 1);
if ($vote2 < 1) { $width2 = 2;}
$percent2 = "$percent2%";
$image_percent2 = "<IMG SRC=\"/hodena/figuren/bar.jpg\" Height=\"10\" Width=\"$width2\">";

$percent3 = ((int(($vote3 / $total) * 1000)) / 10);
$percent3 = substr($percent3,0,4);
if ($vote3 < 1) { $percent3 = "0";}
$width3 = int($percent3 * 1);
if ($vote3 < 1) { $width3 = 2;}
$percent3 = "$percent3%";
$image_percent3 = "<IMG SRC=\"/hodena/figuren/bar.jpg\" Height=\"10\" Width=\"$width3\">";

$percent4 = ((int(($vote4 / $total) * 1000)) / 10);
$percent4 = substr($percent4,0,4);
if ($vote4 < 1) { $percent4 = "0";}
$width4 = int($percent4 * 1);
if ($vote4 < 1) { $width4 = 2;}
$percent4 = "$percent4%";
$image_percent4 = "<IMG SRC=\"/hodena/figuren/bar.jpg\" Height=\"10\" Width=\"$width4\">";

$percent5 = ((int(($vote5 / $total) * 1000)) / 10);
$percent5 = substr($percent5,0,4);
if ($vote5 < 1) { $percent5 = "0";}
$width5 = int($percent5 * 1);
if ($vote5 < 1) { $width5 = 2;}
$percent5 = "$percent5%";
$image_percent5 = "<IMG SRC=\"/hodena/figuren/bar.jpg\" Height=\"10\" Width=\"$width5\">";

print "<body bgcolor=#EFEFEF><p class=\"menu\">";
print "Wat doet Hodena tegen den S-kring?<br><br>";

print "<table class=\"menu\">";
print "<tr><td>zwaar winnen!<td>$image_percent1 $percent1</tr>";
print "<TR><td>Winnen<td>$image_percent2 $percent2</tr>";
print "<TR><td>Nipt winnen<td>$image_percent3 $percent3</tr>";
print "<TR><td>Verliezen<td>$image_percent4 $percent4</tr>";
print "<TR><td>Geen idee<td>$image_percent5 $percent5</tr>";
print "<TR><TD>&nbsp</tr>";
print "<TR><TD>Total votes:<TD>$total</tr>";
print "</table>";
print "<\/body><\/html>";
exit;


### END OF THE CODE ###
 
Forum Index » Support Forum
Go to:   
Based on the open source JForum