Wordpress "prepare" function for inserting into database


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $field1 = "Andy Peatling";
  2. $field2 = "It's like that, and that's the way it is.";
  3.  
  4. $wpdb->query( $wpdb->prepare( "INSERT INTO $wpdb->sometable( id, field1, field2 ) VALUES ( %d, %s, %s )", $_POST['id'], $field1, $field2 );

URL: http://apeatling.wordpress.com/2008/06/25/prepare-dont-escape/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.