PSET 3 - Fifteen - Move Function Not Working - Brain melted and not sure how to proceed. Please help

so I've been stuck on this darn 'move' function for about a week now, and at this point I'm not sure how to move forward with things. At this point, whenever I make a move, I get "Illegal Move".

bool move(int tile)
{

int y = d-1;
int z = d-1;
int empty = board[d-1][d-1]; //location of the '_' tile in the array at the beginning of the game
int tileloc; //location of the inputed tile

for (int i = 0; i < d-1; i++)         //Step 1: Find Tile location (if on board) and save it
{                                   //Finds the tiles location on the board;
for (int j = 0; j < d-1; j++)   //Returns its location through 'tileloc'
{
if (board[i][j] == tile)
{
tileloc = board[i][j];
}

}
}

if (board[y - 1][z] == tileloc)
{
swap(&empty, &tileloc);
return true;
}
else if (board[y + 1][z] == tileloc)
{
swap(&empty, &tileloc);
return true;
}
else if (board[y][z - 1] == tileloc)
{
swap(&empty, &tileloc);
return true;
}
else if (board[y][z + 1] == tileloc)
{
swap(&empty, &tileloc);
return true;
}
else
{
return false;
}

}

The swap function I have is:

void swap(int* ab, int* bc)
{
int temporary = *ab;
*ab = *bc;
*bc = temporary;

};

Thank you for your help! :)