This question already has an answer here:
<?php
require "connection.php";
$cek = mysql_query("SELECT * FROM `kelimeler` ORDER BY `numara` DESC LIMIT 10");
$i = 0;
$tr_dizi = array();
$alm_dizi = array();
while ($satir = mysql_fetch_array($cek)) {
$tr_dizi[$i] = $satir["turkce"];
$alm_dizi[$i] = $satir["almanca"];
$i++;
}
$deger = rand(1,10);
setcookie("soru", $tr_dizi[$deger]);
setcookie("cevap", $alm_dizi[$deger]);
?>
<?php
if (isset($_POST["kelime"])) {
if ($_POST["kelime"] == $_COOKIE['cevap']) {
echo '<div class="bildirim">Richtig ✔</div>';
} else {
echo '<div class="bildirim">'.$_COOKIE['soru'].' = '.$_COOKIE['cevap'].'</div>';
}
}
?>
This is a quiz game like a = b what is a ? if user send b it says 'yes!' else correct answer was 'b' php say
Notice: Undefined offset: 10 on line 19 - 20 - 55
Line 19 -> setcookie("soru", $tr_dizi[$deger]);
Line 20 -> setcookie("cevap", $alm_dizi[$deger]);
Line 55 -> <divclass="kelime"><?php echo $tr_dizi[$deger] ?></div>
when user send the answer program check it and ask new question and yes or no is showing on new page i'm using cookies for that
how can i fix this error i can make error handling but i'm a new developer i want to learn thank you for everybody :)
</div>