Forum » Izdelava spletišč » Vote script(php)-problem?
Vote script(php)-problem?
![](https://static.slo-tech.com/stili/avatar_gray.gif)
AlexUS ::
Hello
Naredu sem eno skripto za glasovanje.
Problem pa je ta, da ko sem skripto testiral v PHPEd programu mi je delal kot bi moralo, a ko sem jo dal na net, mi je vrglo ven error.
Pa tudi štet noče glasov.
Izpiše mi pa tole:
Warning: fopen(plus.txt): failed to open stream: Permission denied in /home/dat1/public_html/votes.php on line 38
Warning: fputs(): supplied argument is not a valid stream resource in /home/dat1/public_html/votes.php on line 40
Warning: fclose(): supplied argument is not a valid stream resource in /home/dat1/public_html/votes.php on line 41
Warning: fopen(neg.txt): failed to open stream: Permission denied in /home/dat1/public_html/votes.php on line 45
Warning: fputs(): supplied argument is not a valid stream resource in /home/dat1/public_html/votes.php on line 46
Warning: fclose(): supplied argument is not a valid stream resource in /home/dat1/public_html/votes.php on line 47
kaj moram spremeniti?
Naredu sem eno skripto za glasovanje.
Problem pa je ta, da ko sem skripto testiral v PHPEd programu mi je delal kot bi moralo, a ko sem jo dal na net, mi je vrglo ven error.
Pa tudi štet noče glasov.
Izpiše mi pa tole:
Warning: fopen(plus.txt): failed to open stream: Permission denied in /home/dat1/public_html/votes.php on line 38
Warning: fputs(): supplied argument is not a valid stream resource in /home/dat1/public_html/votes.php on line 40
Warning: fclose(): supplied argument is not a valid stream resource in /home/dat1/public_html/votes.php on line 41
Warning: fopen(neg.txt): failed to open stream: Permission denied in /home/dat1/public_html/votes.php on line 45
Warning: fputs(): supplied argument is not a valid stream resource in /home/dat1/public_html/votes.php on line 46
Warning: fclose(): supplied argument is not a valid stream resource in /home/dat1/public_html/votes.php on line 47
kaj moram spremeniti?
Modrost ni debelost, debela je norost.
![](https://static.slo-tech.com/stili/avatar_gray.gif)
AlexUS ::
plus.txt in neg.txt nista označena z read-only, niti z hidden.
Saj ne smeta bit, ker se v njih zapisuje št. glasovanja.
Pol se pa iz obeh naredijo procenti za odgovore.
Ka mi je za narediti?
Saj ne smeta bit, ker se v njih zapisuje št. glasovanja.
Pol se pa iz obeh naredijo procenti za odgovore.
Ka mi je za narediti?
Modrost ni debelost, debela je norost.
Zgodovina sprememb…
- spremenilo: AlexUS ()
![](https://static.slo-tech.com/stili/avatar_gray.gif)
AlexUS ::
chmod +plus.txt
chmod +neg.txt
?
tu je del skripte, v kateri prikaže error:
if(isset($_POST['vote'])){
if (!empty($_POST['vote'])){
$vote = $_POST['vote'];
if($vote == "yes") {
$votegd = "plus.txt";
$votebd = "neg.txt";
$abab = "Da";
$baba = "Ne";
} elseif($vote == "no") {
$votegd = "neg.txt";
$votebd = "plus.txt";
$abab = "No";
$baba = "Yes";
} else {
echo "Sorry there was an error.";
}
$fp = fopen($votegd,"r");
$numa = fgets($fp,9999);
fclose($fp);
$fp = fopen($votegd,"w");
$numa += 1;
fputs($fp, $numa);
fclose($fp);
$fpb = fopen($votebd,"r");
$numb = fgets($fpb,9999);
fclose($fpb);
$fpb = fopen($votebd,"w");
fputs($fpb, $numb);
fclose($fpb);
$a = $numa;
$b = $numb;
$num = $a + $b;
$numaa = round($a/$num * 100);
$numbb = round($b/$num * 100);
$anumaa = round($a/$num * 300);
$anumbb = round($b/$num * 300);
$numnum = $a + $b;
chmod +neg.txt
?
tu je del skripte, v kateri prikaže error:
if(isset($_POST['vote'])){
if (!empty($_POST['vote'])){
$vote = $_POST['vote'];
if($vote == "yes") {
$votegd = "plus.txt";
$votebd = "neg.txt";
$abab = "Da";
$baba = "Ne";
} elseif($vote == "no") {
$votegd = "neg.txt";
$votebd = "plus.txt";
$abab = "No";
$baba = "Yes";
} else {
echo "Sorry there was an error.";
}
$fp = fopen($votegd,"r");
$numa = fgets($fp,9999);
fclose($fp);
$fp = fopen($votegd,"w");
$numa += 1;
fputs($fp, $numa);
fclose($fp);
$fpb = fopen($votebd,"r");
$numb = fgets($fpb,9999);
fclose($fpb);
$fpb = fopen($votebd,"w");
fputs($fpb, $numb);
fclose($fpb);
$a = $numa;
$b = $numb;
$num = $a + $b;
$numaa = round($a/$num * 100);
$numbb = round($b/$num * 100);
$anumaa = round($a/$num * 300);
$anumbb = round($b/$num * 300);
$numnum = $a + $b;
Modrost ni debelost, debela je norost.
![](https://static.slo-tech.com/stili/avatar_gray.gif)
AlexUS ::
No pa sem le zrihtu.
Preko "file meneger" sem lepo označu .txt datoteke, ter spremenil permission na 777.
Tako da zdej pa dela!
lp
Preko "file meneger" sem lepo označu .txt datoteke, ter spremenil permission na 777.
Tako da zdej pa dela!
lp
Modrost ni debelost, debela je norost.
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | problem z phpjemOddelek: Izdelava spletišč | 4159 (3572) | snow |
» | EZ portal problem!Oddelek: Izdelava spletišč | 1325 (1245) | roli |
» | zapis v datotekoOddelek: Izdelava spletišč | 958 (836) | sopex |
» | php pollOddelek: Izdelava spletišč | 936 (870) | bodom |
» | PHP help!Oddelek: Programiranje | 1694 (1532) | rc-car |