• Everytime I try to submit a form into the database with INSERT, I get an error:
    Fatal error: Call to a member function prepare() on a non-object in /…/…/saveTemplate.php on line 17

    <?php	global $wpdb;
    
    	$field1 = $_POST['tmplName'];
    
    	$sql = $wpdb->prepare(
         "INSERT INTO 'wp_templates' ('templateName') values ",
          $field1);
    
    $wpdb->query($sql);
    ?>

    Can you please help me?

Viewing 1 replies (of 1 total)
  • wouldn’t it be easier to do:

    global $wpdb;
    $field = array();
    $field['templateName'] = $_POST['tmplName'];
    $sql = $wpdb->insert('wp_templates',$field);

Viewing 1 replies (of 1 total)

The topic ‘Insert to Database from form submit’ is closed to new replies.