Skip to main content
deleted 5 characters in body; edited tags
Source Link
Chris_O
  • 20.6k
  • 5
  • 61
  • 95

itIt just won't insert anything, if i willI echo it, it will show everything fine, but it won't insert anything in database. The table name is correct. Code -

global $wpdb;
$meta2 = get_post_meta($post->ID, 'customFields', true); 
$metas2 = explode(",", $meta2); 
foreach ($meta2 as $meta) 
{ 
$wpdb->query( $wpdb->prepare("INSERT INTO customfields(values) VALUES('$meta')")); 
}

The code is inside Theme functions.php file.

it just won't insert anything, if i will echo it, it will show everything fine, but it won't insert anything in database. The table name is correct. Code -

global $wpdb;
$meta2 = get_post_meta($post->ID, 'customFields', true); 
$metas2 = explode(",", $meta2); 
foreach ($meta2 as $meta) 
{ 
$wpdb->query( $wpdb->prepare("INSERT INTO customfields(values) VALUES('$meta')")); 
}

The code is inside Theme functions.php file.

It just won't insert anything, if I echo it, it will show everything fine, but it won't insert anything in database. The table name is correct. Code -

global $wpdb;
$meta2 = get_post_meta($post->ID, 'customFields', true); 
$metas2 = explode(",", $meta2); 
foreach ($meta2 as $meta) 
{ 
$wpdb->query( $wpdb->prepare("INSERT INTO customfields(values) VALUES('$meta')")); 
}

The code is inside Theme functions.php file.

added 19 characters in body
Source Link
Y2ok
  • 39
  • 4

it just won't insert anything, if i will echo it, it will show everything fine, but it won't insert anything in database. The table name is correct. Code -

global $wpdb;
$meta2 = get_post_meta($post->ID, 'customFields', true); 
$metas2 = explode(",", $meta2); 
foreach ($meta2 as $meta) 
{ 
$wpdb->query( $wpdb->prepare("INSERT INTO customfields(values) VALUES('$meta')")); 
}

The code is inside Theme functions.php file.

it just won't insert anything, if i will echo it, it will show everything fine, but it won't insert anything in database. The table name is correct. Code -

$meta2 = get_post_meta($post->ID, 'customFields', true); 
$metas2 = explode(",", $meta2); 
foreach ($meta2 as $meta) 
{ 
$wpdb->query( $wpdb->prepare("INSERT INTO customfields(values) VALUES('$meta')")); 
}

The code is inside Theme functions.php file.

it just won't insert anything, if i will echo it, it will show everything fine, but it won't insert anything in database. The table name is correct. Code -

global $wpdb;
$meta2 = get_post_meta($post->ID, 'customFields', true); 
$metas2 = explode(",", $meta2); 
foreach ($meta2 as $meta) 
{ 
$wpdb->query( $wpdb->prepare("INSERT INTO customfields(values) VALUES('$meta')")); 
}

The code is inside Theme functions.php file.

Source Link
Y2ok
  • 39
  • 4

wpdb function insert doesn't work

it just won't insert anything, if i will echo it, it will show everything fine, but it won't insert anything in database. The table name is correct. Code -

$meta2 = get_post_meta($post->ID, 'customFields', true); 
$metas2 = explode(",", $meta2); 
foreach ($meta2 as $meta) 
{ 
$wpdb->query( $wpdb->prepare("INSERT INTO customfields(values) VALUES('$meta')")); 
}

The code is inside Theme functions.php file.