Note that there are some explanatory texts on larger screens.

plurals
  1. POunidentifed offset errors php
    primarykey
    data
    text
    <p>I made a simple quiz scoring using PHP but its coming up with unidentifed offset errors, but it works fine.</p> <p>errors:</p> <pre><code>Notice: Undefined offset: 0 in C:\Users\scorequiz1.php on line 17 Notice: Undefined offset: 1 in C:\Users\scorequiz1.php on line 18 Notice: Undefined offset: 2 in C:\Users\scorequiz1.php on line 19 Notice: Undefined offset: 3 in C:\Users\scorequiz1.php on line 20 Notice: Undefined offset: 4 in C:\Users\scorequiz1.php on line 21 Notice: Undefined offset: 0 in C:\Users\scorequiz1.php on line 52 Question 1. Correct. Notice: Undefined offset: 1 in C:\Users\scorequiz1.php on line 52 Question 2. Incorrect. Notice: Undefined offset: 2 in C:\Users\scorequiz1.php on line 52 Question 3. Correct. Notice: Undefined offset: 3 in C:\Users\scorequiz1.php on line 52 Question 4. Correct. Notice: Undefined offset: 4 in C:\Users\scorequiz1.php on line 52 Question 5. Incorrect. </code></pre> <p>line 17 to 21:</p> <pre><code>$data[0] = $_POST["a"]; $data[1] = $_POST["b"]; $data[2] = $_POST["c"]; $data[3] = $_POST["d"]; $data[4] = $_POST["e"]; </code></pre> <p>line 50-56:</p> <pre><code>for($i = 0; $i &lt; 5; $i++) { if($answer[$i] == 1) echo "Question " . ($i+1) . ". " . "Correct.&lt;br/&gt;"; else echo "Question " . ($i+1) . ". " . "Incorrect.&lt;br/&gt;"; } </code></pre> <p>my quiz is just like this. The options for question has the name "a" to "e" and the value to check for the right answer</p> <pre><code>&lt;!-- question 1----&gt; &lt;INPUT TYPE="radio" NAME="a" VALUE="1"&gt;10 days&lt;BR&gt; &lt;INPUT TYPE="radio" NAME="a" VALUE="1"&gt;40 days&lt;BR&gt; &lt;!-- question 2----&gt; &lt;INPUT TYPE="radio" NAME="b" VALUE="1"&gt;True&lt;BR&gt; &lt;INPUT TYPE="radio" NAME="b" VALUE="1"&gt;False&lt;BR&gt; </code></pre> <p>I'm not sure whats wrong</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload