I’m trying to create an INSERT statement for a custom database table I’ve made. Everything I’ve read suggests:
$wpdb->insert( $wpdb->custom_table, array( 'val1' => $newvalueone,'val2' => $newvaluetwo ) );
Am I supposed to declare or initialize my custom table somewhere? I’m not creating a plugin, I’m just creating a custom function (in functions.php) for me.
I can get all my SQL queries to work if I change $wpdb->custom_table into wp_custom_table, but I know that’s not the correct method.
I get this error if I do $wpdb->custom_table:
WordPress database error: [Incorrect table name ''] INSERT INTO <code></code> (<code>val1</code>,<code>val2</code>) VALUES ('Hello World!','http://google.com')
I saw one site that has this code:
but it only works once, within that function. Am I supposed to globally declare it somewhere?
- The topic ‘Simple $wpdb-> question’ is closed to new replies.