Unless that "other php page" is included/required by the original script (or vice versa), then the 2nd script has no knowledge of any variable assignments in the first. If that's the issue, then you may want to look at using session variables. If that's not the issue, then you may need to do more debugging to verify what values are being set and if/when they are getting overridden.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
You might do a print_r on $r, $type[$r] and $vidlink, just after setting in the first block, and just before the anchor in the second block, to make sure they're all as expected. Somewhere, they're not.