Hello all, Long time reader, first time poster. I am getting several undefined offsets when I run my code here. I don't really understand why.
Below is the code and the output from the print_r's that I do to try to troubleshoot the missing offsets. I just am at a loss for what I am missing. Now if it was complaining about the offset being empty, thats one thing, but it is complaining that the offsets do not exist when clearly they do.
The PHP Errors below show that offsets 0 thru 2 can not be found, but the arrays tell a different story. Any ideas?
PHP ERRORS GENERATED:
Notice: Undefined offset: 0 in C:\htdocs\custaccess\scripts\functions.php on line 848
Notice: Undefined offset: 0 in C:\htdocs\custaccess\scripts\functions.php on line 849
Notice: Undefined offset: 0 in C:\htdocs\custaccess\scripts\functions.php on line 850
Notice: Undefined offset: 0 in C:\htdocs\custaccess\scripts\functions.php on line 851
Notice: Undefined offset: 0 in C:\htdocs\custaccess\scripts\functions.php on line 852
Notice: Undefined offset: 0 in C:\htdocs\custaccess\scripts\functions.php on line 853
Notice: Undefined offset: 0 in C:\htdocs\custaccess\scripts\functions.php on line 854
Notice: Undefined offset: 1 in C:\htdocs\custaccess\scripts\functions.php on line 848
Notice: Undefined offset: 1 in C:\htdocs\custaccess\scripts\functions.php on line 849
Notice: Undefined offset: 1 in C:\htdocs\custaccess\scripts\functions.php on line 850
Notice: Undefined offset: 1 in C:\htdocs\custaccess\scripts\functions.php on line 851
Notice: Undefined offset: 1 in C:\htdocs\custaccess\scripts\functions.php on line 852
Notice: Undefined offset: 1 in C:\htdocs\custaccess\scripts\functions.php on line 853
Notice: Undefined offset: 1 in C:\htdocs\custaccess\scripts\functions.php on line 854
Notice: Undefined offset: 2 in C:\htdocs\custaccess\scripts\functions.php on line 848
Notice: Undefined offset: 2 in C:\htdocs\custaccess\scripts\functions.php on line 849
Notice: Undefined offset: 2 in C:\htdocs\custaccess\scripts\functions.php on line 850
Notice: Undefined offset: 2 in C:\htdocs\custaccess\scripts\functions.php on line 851
Notice: Undefined offset: 2 in C:\htdocs\custaccess\scripts\functions.php on line 852
Notice: Undefined offset: 2 in C:\htdocs\custaccess\scripts\functions.php on line 853
Notice: Undefined offset: 2 in C:\htdocs\custaccess\scripts\functions.php on line 854
COUNT STRING VALUE AND ARRAY OUTPUT:
Array ( [id] => Array ( [0] => 7 [1] => 8 [2] => 9 ) )
Array ( [firstname] => Array ( [0] => ZXCzxczxc [1] => dsfdfasdf [2] => 444444444444444 ) )
Array ( [lastname] => Array ( [0] => xzxcz [1] => asdfsadfsdf [2] => 333333333333333333 ) )
Array ( [email] => Array ( [0] => zczxc [1] => asdfdsf [2] => 222222222222 ) )
Array ( [phonenum] => Array ( [0] => zcxzxczxc [1] => asdfsdf [2] => 1111111111111111111 ) )
Array ( [faxnum] => Array ( [0] => [1] => [2] => ) )
Array ( [mobilenum] => Array ( [0] => [1] => [2] => ) )
GLOBAL $siteloc;
$count=$_GET['count'];
//Arrays passed as a post arrays and renamed removing the post superglobal
$id = array ("id"=>$_POST['id']);
$firstname =array ("firstname"=>$_POST['firstname']);
$lastname=array ("lastname"=>$_POST['lastname']);
$email=array("email"=>$_POST['email']);
$phonenum=array("phonenum"=>$_POST['phonenum']);
$faxnum=array("faxnum"=>$_POST['faxnum']);
$mobilenum=array("mobilenum"=>$_POST['mobilenum']);
//debug to see the arrays and make sure they are keyed right.
echo $count.'<P>';
print_r($id);
echo '<br>';
print_r($firstname);
echo '<br>';
print_r($lastname);
echo '<br>';
print_r($email);
echo '<br>';
print_r($phonenum);
echo '<br>';
print_r($faxnum);
echo '<br>';
print_r($mobilenum);
FOR ($i=0;$i<$count;$i++)
{
$sql1="UPDATE customer_contact SET
firstname='$firstname[$i]',
lastname='$lastname[$i]',
phonenum='$phonenum[$i]',
mobilenum='$mobilenum[$i]',
email='$email[$i]',
faxnum='$faxnum[$i]
WHERE id='$id[$i]'";
$result1=mysql_query($sql1);
}