Radoslav Rác Radoslav Rác - 3 years ago 262
PHP Question

Undefined index (2)

I have a little problem here.
Can you help me with this error?

"Notice: Undefined index:"

My code:

$a1 = $_GET['scitovanie_1']; //error
$a2 = $_GET['scitovanie_2']; //error
$b1 = $_GET['odcitovanie_1']; //error
$b2 = $_GET['odcitovanie_2']; //error
$c1 = $_GET['nasobenie_1']; //error
$c2 = $_GET['nasobenie_2']; //error
$d1 = $_GET['delenie_1']; //error
$d2 = $_GET['delenie_2']; //error

if($a1 AND $a2){
$vysledok = $a1 + $a2;

echo $vysledok;
}else if($b1 AND $b2){
$vysledok = $b1 - $b2;

echo $vysledok;
}else if($c1 AND $c2){
$vysledok = $c1 * $c2;

echo $vysledok;
if($d1 AND $d2){
$vysledok = $d1 / $d2;

echo $vysledok;

Thank you for your response.

Answer Source

check for all response variable if isset or not manually

$a1 = isset($_GET['scitovanie_1'])?$_GET['scitovanie_1']:""; 

for all variable so if not set than set value blank

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download