I try different way for insert data in custom table but is not work and there are not errors.
Sometimes is save, but most of the time is not.
I check around the web, but no solution is working for me.
my last method is:
$sql = $wpdb->prepare("INSERT INTO `$table_name`
(`name`, `email`, `phone`, `address`, `message`, `rq`, `url`)
values
(%s, %s, %s, %s, %s, %d, %s)",
$name, $email, $phone, $address, $msg, 1, $url);
$wpdb->query($sql);
I print $sql and paste on phpmyadmin SQL and save it, so the query doesn't have any problem, but still not save.
Why this happen?
I already try with array and $wpdb->insert(), same problem.
EDIT: it is solved. it was an integer passed like string, thanks to everybody
$table_name
. What is the structure of your table? What is the primary key?admin-ajax.php
. This is an important detail.