WordPress Database Error Help Needed
Hi everyone! I’m having trouble with a WordPress database issue. When I try to fetch data from a custom table in my template file, I keep getting this error message:
WordPress database error: [Incorrect table name ‘’] SHOW FULL COLUMNS FROM ``
I’m not sure what’s causing this problem. Here’s the PHP code I’m using:
<?php /* Template Name: checkpayment */
if (!is_user_logged_in()) {
wp_redirect(wp_login_url());
exit;
}
$current_user = get_current_user_id();
global $wpdb;
$transactions = $wpdb->get_results("SELECT transaction_id, total_amount, payment_date FROM wp_stripe_transactions WHERE user_id = $current_user And status = 1 ORDER BY id DESC LIMIT 1");
$recent_payment = $wpdb->get_results("SELECT transaction_id, total_amount, payment_date, processed FROM wp_payment_verification WHERE user_id = $current_user ORDER BY id DESC LIMIT 1");
$datetime = new DateTime($transactions[0]->payment_date);
$current_date = $datetime->format('Y-m-d');
$current_time = $datetime->format('Y-m-d');
if ($current_date = date('Y-m-d')) {
if($wpdb->insert($wpdb->prefix.'payment_verification', array("user_id" => $current_user, "transaction_id" => $transactions[0]->transaction_id, "total_amount" => $transactions[0]->total_amount, "processed" => "Y", "user_email" => $transactions[0]->total_amount, "status" => $transactions[0]->status, "payment_date" => $transactions[0]->payment_date), array("%d", "%s", "%d", "%s", "%s", "%d", "%d"))){
echo 'data inserted successfully';
}
}
Can someone help me figure out what’s wrong with this code? I’m fairly new to WordPress development and would appreciate any guidance. Thanks in advance!