How do I get an external php page to load using javascript

If you’re trying to load a script from an external source (as your code suggests), please don’t use that article as a reference. It’s littered with bad code, and the comments on the page state several times that it’s outdated and points you to a new article.

Here’s how you register and enqueue a script on a specific page (using a cleaned up version of your code):

if ( ! function_exists( 'myscript' ) ) {
    function myscript() {
        if ( is_page( 'ThePage' ) ) {
            wp_register_script( 'myscript', 'http://www.othersite.com/thepage.php?uid=1234' );
            wp_enqueue_script( 'myscript' );
        }
    }
}
add_action( 'wp_enqueue_scripts', 'myscript' );

Here’s what was changed, and why:

if (function_exists('myscript')) {
function myscript() {

You’re saying that if this function exists, then declare a function with the exact same name. This won’t work since you can’t reuse function names. You really wanted to check if the function doesn’t exist.

     if (is_page('ThePage'))

is_page() checks several things to see what page you’re on, specifically

@param mixed $page Page ID, title, slug, or array of such.

Your page better have a title of “ThePage”, or the script won’t load (slugs are all lowercase).

    wp_register_script('myscript', 'http://www.othersite.com/thepage.php?uid=1234'__FILE__); 

This is close to right, but that __FILE__ is just messing up the function call and needs to be removed here. Bad stuff.

add_action('init', 'myscript');

The proper hook for loading your own scripts on non-admin pages is wp_enqueue_scripts.

Now, assuming the script you registered actually returns some valid JavaScript, you’ll see it loaded on the page titled “ThePage”.