Undefined offset


Posted on 16th Feb 2014 07:03 pm by admin

The following script checks to see if the user answer matches the correct answer.

Form Fields are set up the following way...

user_answer[$i] | value = a
user_answer[$i] | value = b
user_answer[$i] | value = c

all radio fields (above)

orgid[$i] | value = $i
answer[$i] | value = (a or b, c)

all hidden fields (above)

$i = question id/number

Basically when question answer isn't selected an undefined offset error message is generated. Adding if empty or isset messes up the order.


Code: foreach ($_POST['orgid'] as $k =>$v) {
$orgid[$k] = $v;
}

$k = 0;
$m = 0;
while ($k <= 19) {
if ($_POST['user_answer'][$k] == $_POST['answer'][$k]) {
$correct++;

unset ($_POST['user_answer'][$k]);
unset ($orgid[$k]);
} else {
$incorrect++;
}
$k++;
}
Any ideas/suggestions?

No comments posted yet

Your Answer:

Login to answer
303 Like 9 Dislike
Previous forums Next forums
Other forums

Read from forum
Haven't written anything forever and I would like to get back.
What I'm trying to do is getting t

Display last record first.
I need some help how put the last record first and first record last.

Thanks

Code: &am

Help adding strtolower( to my in_array
strtolower i need to add it to this to work, iuno how.

Code: $moderators = array('Admin', 'ba

A href problem under php
Hello...

I tried to explain the issue in an earlier post.. but was not clear enough....

Mail from PHP form not always ending up in my inbox?
Hi guys,

I'm a real newbie to PHP and have managed to put together a simple mail form that se

Can I call a class inside a function?
I have a class written in another file that handles my image resizing.

Can I do this (php say

does anyone know a php script to send mail using gmails/googles free smtp server
cause i heard u can do that but i dont know how

import table with dependency
Hi

What is the best way to import table back which has dependency?

SQL> cre

Dealing with code in db query
I am dealing with C code and I need to make sure it is encoded some how to ensure its integrity and

include
Hi I have this way of licensing my PHP application, and I want to know if you guys can answer some q

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash