Hello all, I havent been around here for awhile, but thought I would pop my head in. I’m running into a problem where I keep getting an unknown offset error in my code. Now I do a print_r on my arrays and I see the offsets there, so I am not sure why PHP is complaining and why my script isnt working. So, any help would be appreciated.
[CODE]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);
}
So above is the code causing the issue. Pretty simple stuff really.
Here are the arrays shown in Print_R format.
[CODE]
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] => ) )
The Value of $count is 3
And the errors, PHP executes the FOR loop until $count is reached and then it ends, the problem is that it doesnt seem to recognize that the offsets in the arrays. Any help?:
Notice: Undefined offset: 0 in C:htdocscustaccessscriptsfunctions.php on line 848
Notice: Undefined offset: 0 in C:htdocscustaccessscriptsfunctions.php on line 849
Notice: Undefined offset: 0 in C:htdocscustaccessscriptsfunctions.php on line 850
Notice: Undefined offset: 0 in C:htdocscustaccessscriptsfunctions.php on line 851
Notice: Undefined offset: 0 in C:htdocscustaccessscriptsfunctions.php on line 852
Notice: Undefined offset: 0 in C:htdocscustaccessscriptsfunctions.php on line 853
Notice: Undefined offset: 0 in C:htdocscustaccessscriptsfunctions.php on line 854
Notice: Undefined offset: 1 in C:htdocscustaccessscriptsfunctions.php on line 848
Notice: Undefined offset: 1 in C:htdocscustaccessscriptsfunctions.php on line 849
Notice: Undefined offset: 1 in C:htdocscustaccessscriptsfunctions.php on line 850
Notice: Undefined offset: 1 in C:htdocscustaccessscriptsfunctions.php on line 851
Notice: Undefined offset: 1 in C:htdocscustaccessscriptsfunctions.php on line 852
Notice: Undefined offset: 1 in C:htdocscustaccessscriptsfunctions.php on line 853
Notice: Undefined offset: 1 in C:htdocscustaccessscriptsfunctions.php on line 854
Notice: Undefined offset: 2 in C:htdocscustaccessscriptsfunctions.php on line 848
Notice: Undefined offset: 2 in C:htdocscustaccessscriptsfunctions.php on line 849
Notice: Undefined offset: 2 in C:htdocscustaccessscriptsfunctions.php on line 850
Notice: Undefined offset: 2 in C:htdocscustaccessscriptsfunctions.php on line 851
Notice: Undefined offset: 2 in C:htdocscustaccessscriptsfunctions.php on line 852
Notice: Undefined offset: 2 in C:htdocscustaccessscriptsfunctions.php on line 853
Notice: Undefined offset: 2 in C:htdocscustaccessscriptsfunctions.php on line 854