hiii plzzzz help me out .. i m vry much tensd... i m making a simple program on online testing... it wil run correctly .. but a prblum in the 2,3,4 line it shows the erro.. i will give the code.. after <?php ... 1st 3 lines show error..plzz tell me why....urgent plzzz <?php $id=$_GET['id']; $marks=$_GET['marks']; $selection=$_GET['selection']; $correct=$_GET['is_correct']; if(!($selection=="")) { if($selection==$correct) { $marks+=5; } } echo("<br>Marks :$marks"); mysql_connect("localhost","root",""); mysql_select_db("onlinetesting"); $query="select *from questions where q_id='$id'"; $result=mysql_query($query); $rows=mysql_num_rows($result); if($rows==0) { $tq=$id-1; $correct=($marks/5); $incorrect=($tq-$correct); $tm=($tq*5); echo("<br> Total Question : $tq"); echo("<br> Correct Question : $correct"); echo("<br> incorrect Question : $incorrect"); echo("<br> Total Marks : $marks"); $per=($marks/$tm)*100; echo("<br> Percnetage: $per"); die("<h1>TEST COMPLETED THANKS"); } $i=0; while($i<$rows) { echo("<center><H1>ONLINE TESTING SYSTEM</h1>"); echo("<form action='http://localhost/onlineexam/test.php'>"); echo("<input type='hidden' name='is_correct' value='$is_correct'>"); echo("<input type='hidden' name='marks' value='$marks'>"); $question=mysql_result($result,$i,"quest"); $opa=mysql_result($result,$i,"op1"); $opb=mysql_result($result,$i,"op2"); $opc=mysql_result($result,$i,"op3"); $opd=mysql_result($result,$i,"op4"); $is_correct=mysql_result($result,$i,"is_correct"); echo("<h3> Question No $id:$question</h3>"); echo("<br><input type='radio' value='$opa' name='selection'>$opa"); echo("<br><input type='radio' value='$opb' name='selection'>$opb"); echo("<br><input type='radio' value='$opc' name='selection'>$opc"); echo("<br><input type='radio' value='$opd' name='selection'>$opd"); $id++; echo("<input type='hidden' name='id' value='$id'>"); $i++; echo("<br><input type='submit' value='NEXT'>"); echo("</form></center></html>"); } ?>
noooo .. whole code is just for understanding the program . ..so its easy to identify problum ohh i think its tooo long.. ok fine jst tell me whats the problm in 2,3,4 line .. its give the error Notice: Undefined index: marks in M:\xampp\htdocs\onlineexam\test.php on line 2 Notice: Undefined index: selection in M:\xampp\htdocs\onlineexam\test.php on line 3 Notice: Undefined index: is_correct in M:\xampp\htdocs\onlineexam\test.php on line 4 <?php $id=$_GET['id']; $marks=$_GET['marks']; $selection=$_GET['selection']; problum is just in these three lines...
They aren't fatal errors. They are PHP warnings. It's just letting you know that $_GET['id] is undefined because the "id" param was NOT assigned a value. Use this to avoid warnings: $id = isset($_GET['id']) ? $_GET['id'] : ""; $marks = isset($_GET['marks']) ? $_GET['marks'] : ""; $selection = isset($_GET['selection']) ? $_GET['selection'] : ""; $correct = isset($_GET['is_correct']) ? $_GET['is_correct'] : ""; PHP: