Connect to Drupal database from outside Drupal

I have found several examples that suggest the code below should display the results of a database query.

chdir('/home/sites/zzzzzz.org/public_html/mmclone1')
include_once('./includes/bootstrap.inc');
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
$result = db_query('SELECT title FROM {node}');
print_r ($result);

Drupal is installed in a sub-folder off public_html, mmclone1. I have checked the path with getcwd().

However when the code is run it displays the website with a ‘Page Not Found message for mmclone1/test1.php where test1.php is the file name of the code above.

I must have missed the point on something here !

Drupal version: 


Source: https://www.drupal.org/taxonomy/term/4/feed