Reputation: 1
I'm very new to PHP/MySQL however i believe the code "should" work.
Undefined offset: 0 on line 59 I'm unsure why this error is occurring. Wouldn't count array > 0 prevent the undefined?
$result = mysql_query("select InterestID FROM userinterest WHERE MemberID ='$MemberID'");
$result_array = array();
$result_array2 = array();
$i=0;
while($row=mysql_fetch_array($result)){
$result_array[$i] = $row['InterestID'];
$i++;
}
$results;
for($ID=100; $ID<400; $ID++){
for($XI=0; $XI<4; $XI++){
for($X=0; $X<4; $X++){
$result2 = mysql_query("select InterestID FROM userinterest WHERE MemberID ='$ID'");
while($row2=mysql_fetch_array($result2)){
$result_array2[$i] = $row2['InterestID'];
$i++;
}
if ((count($result_array2[$X]) > 0)) {
if($result_array2[$X] == $result_array[$XI])
{
$match++;
}
}
}
}
if($match>0){mysql_query("INSERT INTO matchtemp(MemberID, Count)VALUES ('$ID','$match')");
}
$match=0;
}
Upvotes: 0
Views: 1152
Reputation: 3680
Why are you doing this?
while($row=mysql_fetch_array($result)){
$result_array[$i] = $row['InterestID'];
$i++;
}
Every time you push an element into an array, its automatically indexed. Try:
while($row = mysql_fetch_array($result)){
$result_array[] = $row['InterestID'];
}
Upvotes: 1