Your while loop will either never be run, or run infinitely (assuming you'd get rid of syntax errors). i and n are not variables in PHP. $i and $n on the other hand would be.
There is a difference between assignment = and comparison ==.
Let's have a look at
while ($i = n)
Assuming $i has been previously defined, and that the constant n hasn't, this should give you some kind of error message (probably E_WARNING or E_NOTICE): use of undefined constant n, assumed 'n'.
That means n is viewed as a constant that has not been defined, and PHP proceeds to assign the string 'n' to this constant.
$i = n will then assign 'n' to $i, which means that your code, at least on the first iteration, is equal to
$i = 'n';
while ($i)
And apart from all the problems you have with incorrect PHP code, have a look at glob