Plugin-dev: inserting data in custom table
-
I am writing a plugin that, when activated, generates a table called wp-events. The events are inserted through a subpanel in the manage menu, with a <form method=”post”>.
Now,I don’t know how and where (in my code) to query the table that I have created.
I tried to hook in to the wp-head, calling this function:// main function, updating the events table
function dbes_action_wp_head() {
global $table_prefix, $wpdb;
if(isset($_POST[‘events_update’])) {
$table_name = $table_prefix.TBNAME;
$event_name =$_REQUEST[‘event_name’]);
$wpdb->query(“INSERT INTO $table_name (name)
VALUES ($event_name)”);
}}
TBNAME is a constant I am using for my custom table.
This code generates an error:
Parse error: parse error, unexpected ‘)’
in the line
$event_name =$_REQUEST[‘event_name’]);I cannot locate my mistake..
Any help will be appreciated.
Cheers,
Davide
The topic ‘Plugin-dev: inserting data in custom table’ is closed to new replies.