wpdb

How to insert data using wpdb

﹥>﹥吖頭↗ 提交于 2019-11-27 09:52:22
问题 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

Issue when trying to use IN() in wpdb

。_饼干妹妹 提交于 2019-11-26 16:54:04
问题 i have this: $villes = '"paris","fes","rabat"'; $sql = 'SELECT distinct telecopie FROM `comptage_fax` WHERE `ville` IN(%s)'; $query = $wpdb->prepare($sql, $villes); when I do an echo $query; i get: SELECT distinct telecopie FROM `comptage_fax` WHERE `ville` IN('\"CHAPELLE VIVIERS \",\"LE MANS \",\"QUEND\"') the probleme i have is that $wpdb add ' in IN('...') can someone help, thanks 回答1: Try this code (FIXED): // Create an array of the values to use in the list $villes = array("paris", "fes"