I don't understand what you mean by stuck.
Syntactically there is no infinite loop here to jam it. It is logically incorrect since you are missing braces which means you'll only ever have the last $row record to work with.
The end result should either be an error message by the die calls, or a redirect to sms_success.php assuming that this page is not sms_success.php. If it is, it will attempt to redirect cyclically, but most modern browsers will detect this and issue a stop.