Skip to main content
added 84 characters in body
Source Link

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.

Thank,

GabrieleEDIT: it is solved. it was an integer passed like string, thanks to everybody

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.

Thank,

Gabriele

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

Source Link

$wpdb insert is not work

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.

Thank,

Gabriele