Hello
I am really hoping someone can please help me with this because I don’t know what I’m doing wrong! I have coded an online Spanish test using MySQL and PHP. I have created a mysql database called practica_1_4_2test. It has 10 columns (because the test had 10 questions) and no index key. It holds the answers of a True or False test. The questions themselves are in the following format:
**[SIZE=2][COLOR=#2f4f4f] <li>Cuba was never discovered by the Spanish.[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] <br /><br /><input type="radio" name="uno" value="t" /> <input type="radio" name="uno" value="f" />[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] <br /><br />True False<br /><br /><br /></li>[/COLOR][/SIZE]**
One radio button has a value of “t” which stands for “true” whilst the other is “f” for “false”. With that in mind I entered all of the data in the “practica_1_4_2test” database as either “f” or “t”. The following script is the processing script that is supposed to get the answers from both the person taking the test and the corresponding fields from the database and compares both of them (for the sake of space and simplicity I have limited it to only three items here so that you get the general idea):
**[SIZE=2][COLOR=#2f4f4f]$query="SELECT * FROM practica_1_4_2test";[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]$result=mysql_query($query);[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]
[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]$num=mysql_num_rows($result);[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]mysql_close();[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]
[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]$i=0;[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]while ($i < $num) {[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]
[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]$q1=mysql_result($result,$i,"q1");[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]$q2=mysql_result($result,$i,"q2");[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]$q3=mysql_result($result,$i,"q3");[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]
[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]
[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]
[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]
[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]
[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] $uno = $_POST['uno'];[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] $dos = $_POST['dos'];[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] $tres = $_POST['tres'];[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]
[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] echo "<p><img src=\"images/exercise_iv.png\" width=\"120\" height=\"27\"><br />";[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]
[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] echo "<b>Answer True/False to the Questions that follow.<br /><br />";[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]
[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] if ( $uno == $q1 ) {[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] $a = 1;[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] echo "<p><font color=\"#7E4B01\" size=\"+1\">\"Cuba was never discovered by the Spanish.\"</font> False is correct!</p>";[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]} else {[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] $a = 0;[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] echo "<p><font color=\"#7E4B01\" size=\"+1\">\"Cuba was never discovered by the Spanish.\"</font> <font color=\"#F00\" size=\"+1\">True</font> is wrong!</p>";[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]}[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]
[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] if ( $dos == $q2 ) {[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] $b = 1;[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] echo "<p><font color=\"#7E4B01\" size=\"+1\">\"Pedro is a Spanish first name.\"</font> True is correct!</p>";[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]} else {[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] $b = 0;[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] echo "<p><font color=\"#7E4B01\" size=\"+1\">\"Pedro is a Spanish first name.\"</font> <font color=\"#F00\" size=\"+1\">False</font> is wrong!</p>";[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]}[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]
[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] if ( $tres == $q3 ) {[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] $c = 1;[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] echo "<p><font color=\"#7E4B01\" size=\"+1\">\"The only language spoken in Spain is Spanish.\"</font> False is correct!</p>";[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]} else {[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] $c = 0;[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] echo "<p><font color=\"#7E4B01\" size=\"+1\">\"The only language spoken in Spain is Spanish.\"</font> <font color=\"#F00\" size=\"+1\">True</font> is wrong!</p>";[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]}[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]
[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]
[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]$ex1sum = $a + $b + $c;[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]$ex1percent = ($ex1sum/3)*100;[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]
[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] echo "<p>You scored <b>$ex1sum</b> out of 3 total marks in Exercise IV.</p>";[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] [/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] if ($ex1percent >= 0 && $ex1percent <= 50)[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] echo "<p><img src=\"images/exam_sorry_01.jpg\" width=\"287\" height=\"25\" alt=\"\" border=\"0\"><a href=\"frmone_practica_4_5_2.php\"><img src=\"images/exam_sorry_02.jpg\" width=\"63\" height=\"25\" alt=\"\" border=\"0\"></a></p>"; [/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] [/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] if ($ex1percent >= 51 && $ex1percent <= 84)[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] echo "<p><img src=\"images/exam_tryagain_01.jpg\" width=\"210\" height=\"25\" alt=\"\" border=\"0\"><a href=\"frmone_practica_4_5_2.php\"><img src=\"images/exam_tryagain_02.jpg\" width=\"68\" height=\"25\" alt=\"\" border=\"0\"></a></p>";[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] [/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] if ($ex1percent >= 85 && $ex1percent <= 100)[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f] echo "<p><img src=\"images/exam_muybueno.jpg\" width=\"80\" height=\"25\" alt=\"\" border=\"0\"></p>";[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]
[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]$i++;[/COLOR][/SIZE]**
**[SIZE=2][COLOR=#2f4f4f]}[/COLOR][/SIZE]**
The rest of script figures out the total score and tabulates percentage. I checked the connection; it is connecting to the database but for some reason no matter what the person taking the test enters the answer always comes up wrong even if it exactly correlates to the data in the database.
What am I doing wrong? Can anyone please help?!!!