I'm trying to insert a new table row into a custom wpdb
table. The data is coming from a form posted to a script.
I'm declaring global $wpdb
at the start of the script, and inserting into the db, but for some reason it doesn't like the query function, which WordPress recommends to use in the codex.
// declare global wpdb
global $wpdb;
// set variables for posting to db
$name = $_POST['name'];
$email = $_POST['email'];
// post to the db
$wpdb->query( $wpdb->prepare(
"
INSERT INTO $wpdb->entries
( name, email )
VALUES ( %s, %s )
",
$name,
$email
) );
Any ideas as to why it's bugging out?
NULL
– lukeseager Sep 12 '13 at 8:50$wpdb = new someObject()...
, do you include this file, of is your file included by some of wordpress' inner files? Because if it's a standalone file, nothing will happen, $wpdb comes from nowhere – Royal Bg Sep 12 '13 at 8:51wp-load.php
let it connect to the databse, now the var_dump shows the connection. Thanks! – lukeseager Sep 12 '13 at 9:04