$offset is supposed to be numerical, but you are assigning a string to it in the while itself:
echo $offset = $stringpos + $search_length.'
';
After this line, $offset is no longer a number and the second time the while is executed, you'd get that notice