Your original $mid statements are correct - they chop the text up into bits. If the variables are not saved, this is not an error with $mid.