View Full Version : problema em php


Nemmesyz
10-04-2008, 18:14
eu sou iniciado em php e tenho um problema em k não consigo criar echos com as escolhas de um painel de checkboxes

<?php
$esc1 = $_GET["questionario"];
if ($esc1 == 1) {$resp1 = 'Ssfg';}
if ($esc1 == 2) {$resp1 = 'dddd';}

$esc2 = $_GET["questionario"];
if ($esc2 == 3) {$resp2 = 'gbbb'; }
if ($esc2 == 4) {$resp2 = 'gbbb'; }

$esc3 = $_GET["questionario"];
if ($esc3 == 5) {$resp3 = 'gbbfdbb'; }
if ($esc3 == 6) {$resp3 = 'gbbb'; }

$esc4 = $_GET["questionario"];
if ($esc4 == 7) {$resp4 = 'gbbb'; }
if ($esc4 == 8) {$resp4 = 'gbbdfb'; }

$esc5 = $_GET["questionario"];
if ($esc5 == 9) {$resp5 = 'ggbbb'; }
if ($esc5 == 10) {$resp5 = 'gbbb'; }

$esc6 = $_GET["questionario"];
if ($esc6 == 11) {$resp6 = 'gbxbbb'; }
if ($esc6 == 12) {$resp6 = 'gbbb'; }

$esc7 = $_GET["questionario"];
if ($esc7 == 13) {$resp7 = 'gdfgbbb'; }
if ($esc7 == 14) {$resp7 = 'gbbb'; }

$esc8 = $_GET["questionario"]
if ($esc8 == 15) {$resp8 = 'gbfbb'; }
if {$resp8 = 16) {$resp8 = "blablabal"; }

echo $resp1 ;
echo $resp2 ;
echo $resp3 ;
echo $resp4 ;
echo $resp5 ;
echo $resp6 ;
echo $resp7 ;
echo $resp8 ;
?>

as respostas são essas só até funcionar, mas basicamente são perguntas com sim ou não. Eu tenho um erro klk de sintaxe (digo eu) k nem entro na pag. dá-me erro http 500. quanto á pag onde estão as perguntas n tem erro nenhum pk já pus a funcionar com uma pergunta de cada vez.
Aposto que é um erro estupido...

Nemmesyz
10-04-2008, 19:06
já está a funcionar...mas só um de cada vez. n me manda o echo para mais do k uma escolha

<?php
$esc1 = $_GET["questionario"];
if ($esc1 == 1) {$resp1 = 'Ssfg';}
if ($esc1 == 2) {$resp1 = 'dddd';}
echo $resp1 ;
$esc2 = $_GET["questionario"];
if ($esc2 == 3) {$resp2 = 'gbbb'; }
if ($esc2 == 4) {$resp2 = 'gbbb2'; }
echo $resp2 ;
$esc3 = $_GET["questionario"];
if ($esc3 == 5) {$resp3 = 'gbbfdbb'; }
if ($esc3 == 6) {$resp3 = 'gbbb'; }
echo $resp3 ;
$esc4 = $_GET["questionario"];
if ($esc4 == 7) {$resp4 = 'gbbb'; }
if ($esc4 == 8) {$resp4 = 'gbbdfb'; }
echo $resp4 ;
$esc5 = $_GET["questionario"];
if ($esc5 == 9) {$resp5 = 'ggbbb'; }
if ($esc5 == 10) {$resp5 = 'gbbb'; }
echo $resp5 ;
$esc6 = $_GET["questionario"];
if ($esc6 == 11) {$resp6 = 'gbxbbb'; }
if ($esc6 == 12) {$resp6 = 'gbbb'; }
echo $resp6 ;
$esc7 = $_GET["questionario"];
if ($esc7 == 13) {$resp7 = 'gdfgbbb'; }
if ($esc7 == 14) {$resp7 = 'gbbb'; }
echo $resp7 ;
$esc8 = $_GET["questionario"];
if ($esc8 == 15) {$resp8 = 'gbfbb'; }
if ($esc8 == 16) {$resp8 = "blablabal"; }
echo $resp8 ;
?>

agradecia k ajudassem

hostmake
10-04-2008, 20:06
tu vais sempre buscar a mesma variável!

e essa só pode ter 1 valor..

Nemmesyz
11-04-2008, 13:55
n tem o mm valor... a form tem 8 perguntas com sim ou não e todos têm um valor. A pag em html envia os valores das várias opções:
localhost/resposta.php?questionario=1&questionario=4&questionario=6&questionario=8&questionario=9&questionario=11&questionario=14&questionario=15 (http://localhost/resposta.php?questionario=1&questionario=4&questionario=6&questionario=8&questionario=9&questionario=11&questionario=14&questionario=15)

agora o problema é k a parte em php n acumula os valores

naoliveira
11-04-2008, 14:21
Experimenta alterar o nome das varáveis em vez de teres 8 variáveis chamadas questionario (como é que o programa sabe a qual delas te referes quando a chamas?) tens que ter 8 variáveis com nomes diferentes, quest1,quest2,..., quest8

Nemmesyz
11-04-2008, 14:42
ya era isso!
obrigadão