Page 1 of 1

Why am I getting this error?

Posted: Thu Apr 26, 2007 11:04 am
by McManCSU
Undefined index: thisEthernet

Here is the relevent code:

Where it is choking:

Code: Select all

function process()
...

if (($_POST[THIS_ETH] >= 0) && ($_POST[THIS_ETH] < getNumberEthPorts())) <== CHOKES HERE
	{
	    // Ethernet number is not valid (not sure how this could happen)
	    echo '<script language="Javascript">';
	    echo "alert('$no_ethnum ($_POST[THIS_ETH])')";
	    echo '</script>';
	    
	    $isError = true;
	}
...
Where THIS_ETH is set:

Code: Select all

function display()
...
echo $tab3 . '<select name="THIS_ETH" onChange="window.alert(\'' . $etheralertText.'\')"' . ">\n";
...
Where THIS_ETH is defined:

Code: Select all

function constants()
...
define('THIS_ETH', 'thisEthernet');
...
The funny thing is, is that in the error message, it prints the corrent value of the THIS_ETH!? See:

Code: Select all

Array
(
    [THIS_ETH] => 4
...
)

Posted: Thu Apr 26, 2007 11:11 am
by volka

Code: Select all

<?php
define('foo', 'bar');
echo foo;

// but you have
echo '  foo  ';
?>

Posted: Thu Apr 26, 2007 11:22 am
by superdezign
Not exactly. Kind of the opposite actually.

Since you defined THIS_ETH as thisEthernet, $_POST[THIS_ETH] is actually $_POST['thisEthernet'], but there is not a 'thisEthernet' field being posted, thus, the index 'thisEthernet' does not exist in $_POST.

Either use $_POST['THIS_ETH'] or change your fieldname to 'thisEthernet.'

Posted: Thu Apr 26, 2007 11:56 am
by volka
superdezign wrote:Not exactly. Kind of the opposite actually.
I meant
McManCSU wrote:echo $tab3 . '<select name="THIS_ETH" onChange="window.alert(\'' . $etheralertText.'\')"' . ">\n";
which actually is exactly like echo ' foo '; ;)