我使用print_r()
Array ( [0] => test [1] => [email protected] [2] => 1.00 [3] => 21:16:36 Jun 04, 2015 PDT [4] => 9DS7592P74GMN )
现在我想在自定义表中添加此数据,但我不能。
这是我的密码
if(!empty($_POST))
{
$player_name = $_POST[\'first_name\'];
$payer_email = $_POST[\'payer_email\'];
$payment_gross = $_POST[\'payment_gross\'];
$payment_date = $_POST[\'payment_date\'];
$payer_id = $_POST[\'payer_id\'];
$paypal_str = array($player_name, $payer_email, $payment_gross, $payment_date, $payer_id);
print_r($paypal_str);
global $wpdb;
$wpdb->insert(
\'paypal\',
array(
\'name\' => $paypal_str[0],
\'email\' => $paypal_str[1],
\'amount\' => $paypal_str[2],
\'player_id\' => $paypal_str[3],
\'date\' => $paypal_str[4],
)
);
}
SO网友:sarath
if(!empty($_POST))
{
$player_name = $_POST[\'first_name\'];
$payer_email = $_POST[\'payer_email\'];
$payment_gross = $_POST[\'payment_gross\'];
$payment_date = $_POST[\'payment_date\'];
$payer_id = $_POST[\'payer_id\'];
$paypal_str = array($player_name, $payer_email, $payment_gross, $payment_date, $payer_id);
print_r($paypal_str);
global $wpdb;
$wpdb->insert(
\'paypal\',
array(
\'name\' => $paypal_str[0],
\'email\' => $paypal_str[1],
\'amount\' => $paypal_str[2],
\'player_id\' => $paypal_str[3],
\'date\' => $paypal_str[4]
)
);
}
从数组中删除不需要的逗号。
SO网友:user3463054
嘿,伙计们,它工作正常。
if(!empty($_POST)){
global $wpdb;
$player_name = $_POST[\'first_name\'];
$payer_email = $_POST[\'payer_email\'];
$payment_gross = $_POST[\'payment_gross\'];
$payment_date = $_POST[\'payment_date\'];
$payer_id = $_POST[\'payer_id\'];
$wpdb->insert(
\'wp_paypal\',
array(
\'name\' => $player_name,
\'player_id\' =>$payer_id,
\'email\' => $payer_email,
\'amount\' => $payment_gross,
\'payment_date\' => $payment_date
),
array(
\'%s\',
\'%s\',
\'%s\',
\'%s\',
)
);
}