twistoff
02-12-2005, 11:14 PM
HI,
I'm trying to rework the voting (http://www.actionscript.org/tutorials/intermediate/Vote_system_flash_php_mySQL/index.shtml) script written by August Jørgensen to work with multiple questions.
I've successfully output the string (choiceFour=19&choiceThree=10&choiceTwo=5&choice=2) from the Flash questions with help from scot in the ActionsScript forum and am now trying to import the string into php.
It seems no matter what I try the php script only picks up one of the four answers/variables from the four Flash questions an only updates one field (and usually the wrong one) to the DB - it should update four fields.
Any ideas? Here's what I have - this is my latest broken version - using the switch command (only because I gave up on if, esleif!).
//Bring in the answers from the four Flash Questions
$choice = $_POST['choice'];
$choiceTwo = $_POST['choiceTwo'];
$choiceThree = $_POST['choiceThree'];
$choiceFour = $_POST['choiceFour'];
//User, password & database
$user="theusername";
$password="thepassword";
$database="thedatabase";
mysql_connect(localhost,$user,$password);
mysql_select_db($database) or die( "Unable to connect to database");
// Question 1 using the php switch feature to check what choice was made in the frist Flash radio group
switch ($choice)
{
case 1
$query="UPDATE votesystem SET vote1=vote1+1";
break;
case 2
$query="UPDATE votesystem SET vote2=vote2+1";
break;
case 3
$query="UPDATE votesystem SET vote3=vote3+1";
break;
}
// Question 2 using the php switch feature to check what choice was made in the second Flash radio group
switch ($choiceTwo)
{
case 4
$query="UPDATE votesystem SET vote4=vote4+1";
break;
case 5
$query="UPDATE votesystem SET vote5=vote5+1";
break;
case 6
$query="UPDATE votesystem SET vote6=vote6+1";
break;
}
// Question 3 using the php switch feature to check what choice was made in the Flash pulldown menu
switch ($choiceThree)
{
case 8
$query="UPDATE votesystem SET vote8=vote8+1";
break;
case 9
$query="UPDATE votesystem SET vote9=vote9+1";
break;
case 10
$query="UPDATE votesystem SET vote10=vote10+1";
break;
case 11
$query="UPDATE votesystem SET vote11=vote11+1";
break;
case 12
$query="UPDATE votesystem SET vote12=vote12+1";
break;
case 13
$query="UPDATE votesystem SET vote13=vote13+1";
break;
case 14
$query="UPDATE votesystem SET vote14=vote14+1";
break;
case 15
$query="UPDATE votesystem SET vote15=vote15+1";
break;
case 16
$query="UPDATE votesystem SET vote16=vote16+1";
break;
case 17
$query="UPDATE votesystem SET vote17=vote17+1";
break;
}
// Question 4 using the php switch feature to check what choice was made in the fourth Flash radio group
switch ($choiceFour)
{
case 18
$query="UPDATE votesystem SET vote18=vote18+1";
break;
case 19
$query="UPDATE votesystem SET vote19=vote19+1";
break;
}
Any direction would be Greatly appreciated, thanks.
Rob
I'm trying to rework the voting (http://www.actionscript.org/tutorials/intermediate/Vote_system_flash_php_mySQL/index.shtml) script written by August Jørgensen to work with multiple questions.
I've successfully output the string (choiceFour=19&choiceThree=10&choiceTwo=5&choice=2) from the Flash questions with help from scot in the ActionsScript forum and am now trying to import the string into php.
It seems no matter what I try the php script only picks up one of the four answers/variables from the four Flash questions an only updates one field (and usually the wrong one) to the DB - it should update four fields.
Any ideas? Here's what I have - this is my latest broken version - using the switch command (only because I gave up on if, esleif!).
//Bring in the answers from the four Flash Questions
$choice = $_POST['choice'];
$choiceTwo = $_POST['choiceTwo'];
$choiceThree = $_POST['choiceThree'];
$choiceFour = $_POST['choiceFour'];
//User, password & database
$user="theusername";
$password="thepassword";
$database="thedatabase";
mysql_connect(localhost,$user,$password);
mysql_select_db($database) or die( "Unable to connect to database");
// Question 1 using the php switch feature to check what choice was made in the frist Flash radio group
switch ($choice)
{
case 1
$query="UPDATE votesystem SET vote1=vote1+1";
break;
case 2
$query="UPDATE votesystem SET vote2=vote2+1";
break;
case 3
$query="UPDATE votesystem SET vote3=vote3+1";
break;
}
// Question 2 using the php switch feature to check what choice was made in the second Flash radio group
switch ($choiceTwo)
{
case 4
$query="UPDATE votesystem SET vote4=vote4+1";
break;
case 5
$query="UPDATE votesystem SET vote5=vote5+1";
break;
case 6
$query="UPDATE votesystem SET vote6=vote6+1";
break;
}
// Question 3 using the php switch feature to check what choice was made in the Flash pulldown menu
switch ($choiceThree)
{
case 8
$query="UPDATE votesystem SET vote8=vote8+1";
break;
case 9
$query="UPDATE votesystem SET vote9=vote9+1";
break;
case 10
$query="UPDATE votesystem SET vote10=vote10+1";
break;
case 11
$query="UPDATE votesystem SET vote11=vote11+1";
break;
case 12
$query="UPDATE votesystem SET vote12=vote12+1";
break;
case 13
$query="UPDATE votesystem SET vote13=vote13+1";
break;
case 14
$query="UPDATE votesystem SET vote14=vote14+1";
break;
case 15
$query="UPDATE votesystem SET vote15=vote15+1";
break;
case 16
$query="UPDATE votesystem SET vote16=vote16+1";
break;
case 17
$query="UPDATE votesystem SET vote17=vote17+1";
break;
}
// Question 4 using the php switch feature to check what choice was made in the fourth Flash radio group
switch ($choiceFour)
{
case 18
$query="UPDATE votesystem SET vote18=vote18+1";
break;
case 19
$query="UPDATE votesystem SET vote19=vote19+1";
break;
}
Any direction would be Greatly appreciated, thanks.
Rob