我正在编写一个自定义查询,以创建指向特定用户名的链接。用户将登录,然后可以单击指向该用户名的链接。我在php中运行查询时收到警告和错误。
警告是:
在/home/中调用的wpdb::prepare()缺少参数2/public\\u html/wp-content/plugins/insert-php-code-snippet/shortcode-handler。php(72):eval()\'d代码位于第22行并已定义
错误是:
您的SQL语法有错误;检查与您的MariaDB服务器版本相对应的手册,以了解在第1行中使用“a.id=b.customer\\u id join as c on b.appointment\\u id=c.id”的正确语法
我的查询:
global $wpdb;
//the query
$currentuserid = wp_get_current_user();
$havelesson = $wpdb->query(
$wpdb->prepare(
"
SELECT e.user_login FROM $wpdb->ab_customers as a
join $wpdb->ab_customer_appointments as b on a.id = b.customer_id
join $wpdb->ab_appointments as c on b.appointment_id = c.id
join $wpdb->ab_staff as d on b.appointment_id = c.id
join $wpdb->users as e on d.wp_user_id = e.id
where a.wp_user_id = $currentuserid->ID
and start_date > now()
order by start_date asc
Limit 1
"
)
);
什么可能导致错误和警告?