I am starting out plugin development and have followed the tutorials on the WordPress Codex sites. I am now stuck - I have a database called \"wp_imlisteningto\", where the
You've probably figured this out by now, but no one addressed it here. Your sample code has '$s' in the 3rd parameter (2nd array), but that should be '%s' because it's for value-formatting. The WP Codex says [http://codex.wordpress.org/Class_Reference/wpdb] that this format parameter for $wpdb->insert() is optional.
Try this..
<?php
global $wpdb;
$wpdb->insert( $table_name, array( 'album' => "$_POST['album']", 'artist' => "$_POST['artist']" ) );
?>
Ex :
<?php
global $wpdb;
$wpdb->insert($table_name , array('chart_name' => "Line Chart" ,'chart_type' => "trends",'status' => 0));
?>
I think there are 2 mistakes in you sql string.
Think it should be the $table_name
variable should be concatenated
$sql = "CREATE TABLE" . $table_name . "(
id mediumint(9) AUTO_INCREMENT,
album VARCHAR(50),
artist VARCHAR(50),
PRIMARY KEY (id)
)";
and remove ;
on the last line.
including
require_once('../../../wp-config.php');
worked for me