I'm developing my own theme and I currently work on a script that validates form data sends an email and puts the details into a second databse.
In the Codex I saw how to connect to a second database, but I was unable to find an answer to a way more important question. How can I access the wpdb class?
The script file is just a script, that outputs a json-encoded array which is needed for my ajax request, so I did not include any headers, footers or other parts that may import wordpress functions.
Locically when running my code, the script says, that the class wpdb is unknown. But I wonder how to include that class and all the other wordpress functions, classes, objects etc.
Thanks for your help. :)
PS: What could be interesting to say, is that I placed the file in a folder which I named inc
. So it isn't in the main directory of the theme but one level up!
theme-directory > inc > file.php