By emmanuel37 on
Hi,
I need to access the drupal database for a stand-alone PHP script which is in a sub folder in the root directory.
I added include_once('includes/bootstrap.inc') and drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE) in my script. I am able to query from the root (eg: http://www.mydomian/drupal/test.php). However I would prefer to put my script into a folder (eg: http://www.mydomian/drupal/myfolder/test.php), but I can't access the database.
I have tried to change the syntax, but I still can't access the database. I'm using a windows box. Please help.
Emmanuel
Comments
...
You can, but you'll have to do
chdir('../../../../..')before you include Drupal's libraries. You may be able to dochdir()to return to your original directory, but if some Durpl function later doesinclude('./something')it will fail.That's sad. I've complained about this before, but it seems people aren't bothered.
--
Help save BLOCKQUOTE
Similar problem, but less far along....
I can't seem to find a simple "how to" anywhere. Like Emmanuel, I want to access Drupal from a stand-alone php script.
My test drupal installation is at /usr/share/drupal; http://www.foo.com/drupal gets me to my drupal home page.
I have added the following two lines to the top of my php script /usr/share/drupal/mypage.php:
Then, logged in as root and cd to /usr/share/drupal, I type:
and I get:
Can someone just simply explain what I need to type or set to simply get past boostrap.inc and run my script?
(Aside: These Drupal forums are short on answers to simple "getting started" questions and my "Pro Drupal Development" book is no help either....)
Huh?
Surprise, surprise. Despite the "PHP Notices" above, my script works. Still:
This worked for me in D6
Working on an older D6 site where I need to write some data to the Drupal database and use a few of the basic Drupal functions. This worked for me:
Thanks to the OP!
__________
Regards,
Chad Hester