• From a particular page, I have a form that sends data to a JS, which then sends a $_POST request to a file called post.php

    post.php accesses a database (a different database to the WP), and then outputs the data back to the JS script, which is then written to the screen.

    It’s very simple AJAX talking to a server-side database.

    I’m trying to use wpdb. The problem is that the post.php script doesn’t recognise WordPress functions. I’ve tried require() and require_once() with wp_config.php, wp_blog_header.php, and wp_load.php (this last one is recommended by the codex article on wpdb).

    The require() isn’t throwing any errors, but the wordpress functions are still unrecognised.

    Any help with this? Or any idea how I can interact with a database with JS in a let clumsy way? I found that WP would muck around with $_POST when I tried to write this as a plugin. I need this finished by the weekend, and I’m scraping the barrel for any hack that will work. No longer have time to do it properly.

Viewing 1 replies (of 1 total)
  • Sounds to me like the wp-config or wp-load files aren’t actually being loaded properly and your site might be set to not show PHP errors so you’re not seeing the error. Or you might not see the error because it’s being generated in the background and it’s not being passed back to frontend code that could display the error.

    Double check the path to the file that you define. You either have to make it the full path (e.g. something like /home/myusername/blog/wp-config.php) or a relative path (e.g. ../../../wp-config.php)

Viewing 1 replies (of 1 total)

The topic ‘WordPress functions aren’t being recognised by script’ is closed to new replies.