you can put the following line at the top of the page...
if (!eregi("thisfile.php", $PHP_SELF)) { die ("Access Denied"); }
what this says is "if this file is opened directly in a browser, give the message access denied and stop."
if you have to use htaccess, a "deny from all" may help. maybe you can change this to only allow a certain ip, and put in the localhost ip (127.0.0.1), ie "allow from 127.0.0.1".
not sure