How do I get an if statement nested in a while statement to work?

I want to run a while loop which contains a nested if statement. When I click submit in my html document, I expect to receive the value of $ex, but instead the page freezes.

I have tested my variables and each works. I have also ran a while loop and if statement independently to ensure they are working. Lastly, I have searched related questions for over an hour and have not find any question pertinent to my situation.

Here is my html.

<html>
<body>

<form method="post" action="baseNum.php">

Enter a number you wish to convert
<input type="text" name="number">
<br>
<select name="baseChoice">
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
  <option value="6">6</option>
  <option value="7">7</option>
  <option value="8">8</option>
  <option value="9">9</option>
</select>
<br><br>
<input type="submit" name="Submit">

</form>

</body>
</html>

Here is my php.

<html>
<body>

<?php
$base = htmlspecialchars($_POST['number']);
$baseNum = htmlspecialchars($_POST['baseChoice']);
$baseEx = 0;
$ex = 0;
$boo = True;

while ($boo == True) {
  $baseNum ** $ex = $baseEx;
  if ($baseEx <= $base) {
    $ex = $ex + 1;
  } else {
    $boo = False;
  }
}

echo $ex;
?>

</body>
</html>