I have wriiten as following
$name="Kumkum";
$email="kumkum@gmail.com";
$phone="3456734567";
$country="India";
$course="Database";
$message="hello i want to read db";
$now = new DateTime();
$datesent=$now->format('Y-m-d H:i:s');
global $wpdb;
$sql = $wpdb->prepare(
"INSERT INTO `wp_submitted_form` (`name`,`email`,`phone`,`country`,`course`,`message`,`datesent`) values ("
$name, $email, $phone, $country, $course, $message, $datesent. ')")';
$wpdb->query($sql);
It's not working... It throws error... Please help me in correcting it.
Problem in your SQL :
You can construct your sql like this :
You can also use
$wpdb->insert()
Use
$wpdb->insert()
.Try this
I recently leaned about
$wpdb->prepare
HERE and added into our Free Class Booking plugin, plugin approved on wordpress.org and will live soon:Thanks -Frank
Just use
wpdb->insert(tablename, coloumn, format)
and wp will prepare that's queryYou have to check your
quotes
properly,OR you can use like,
Read http://codex.wordpress.org/Class_Reference/wpdb