valid is not tracking it's previous state. When you exit out of the loop, valid only has the state of the last comparison, not the state of all comparison upto and including the last. Line 22-25 should look like this:
1 2 3 4 5 6 7
valid = true; // Assume it's a palindrome to start
for (int i = 0, p = length; p > i; i++, p--)
{ if (toupper(word[i]) != toupper(word[p]))
{ valid = false;
break; // no point in checking any further
}
}