<?php
//Distance Function
function distance($findId, $userToSearch, $userids, &$nodes){
$searchquery="SELECT '($findId)' FROM 'users' WHERE userid='($userToSearch)'";
$queryResult=mysql_query($searchquery);
while($blah=mysql_fetch_assoc($queryResult))
{
$result=$blah["$findId"];
}
if($result == '1'){
return 1;
}
else{
$userToSearch=array_pop($userids);
if($userToSearch!=NULL){
$count=(distance($findId,$userToSearch, $userids, &$nodes)+1);
}
return $count;
}
echo "Search Failed. <br>";
return 0;
}
$SQL2 = "SELECT userid FROM `users`";
$query2=mysql_query($SQL2);
while($userid_temp=mysql_fetch_assoc($query2))
{
$userids[]=$userid_temp['userid'];
}
$nodes=1;
$userToSearch=$fb_user;
$key=array_search($fb_user,$userids);
unset($userids[$key]);
foreach($userids as $value){
$searchquery="SELECT ($value) FROM `users` WHERE userid=($fb_user)";
$result0=mysql_query($search_query);
if($result0==NULL){
$key=array_search($value,$userids);
unset($userids[$key]);
}
}
//Get specific columns
$result = mysql_query("SHOW COLUMNS FROM users");
$searchId=array();
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$searchId[] = $row['Field'];
}
$key=array_search("userid",$searchId);
unset($searchId[$key]);
}
foreach($searchId as $findId){
$distance=distance($findId,$userToSearch,$userids,&$nodes);
echo $findId;
echo ": ";
echo $distance;
echo "<br>";
}
echo "updateData Operation completed. <br>";
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>";
?>
This is supposed to be a facebook application that gets the userids of those who have entered the program(that part works fine), determines the columns that it searches as an undirected graph for a connection(determined by an identity matrix with value= '1' for connected), and searches for the distance between the nodes. The distance function does not work, and im 98% sure it has to do with the mysql call. Please advise.