I have placed my own php file in /sites/all/modules/<myfolder> and call it via $.post(<myphppage>)
from a static html page (javascript function) also in /sites/all/modules/<myfolder>.
However, the php does not appear to be executing as expected, but is getting called (access logs in Apache HTTPD show it is post'ed to).
If I try to manually request the same php page, I receive this error:
Fatal error: Call to undefined function db_insert() in /full/path/to/sites/modules/<myfolder>/<myphppage> on line x.
The echo
statement I have in the php page is outputted properly above this error, and simply uses $_GET['paramname']
. (And _POST, changed for testing direct request) to print a few query string parameters for debugging).
Also, when I added a call to watchdog
, I receive:
Fatal error: Call to undefined function watchdog() in /full/path/to/sites/modules/<myfolder>/<myphppage> on line x.
Is it not possible to access the PHP page directly? Or is there a Drupal library I need to import? Or am I just plain missing something else with how Drupal works?