admin管理员组文章数量:1415460
I am working in a wordpress site, I started to work in local enviroment using xampp server.
I used wpdb to do operations with the database like this:
global $wpdb;
$name = $wpdb->get_results("SELECT meta_value FROM wp_usermeta WHERE meta_key = 'first_name' AND user_id = ".$user." ");
$wpdb->update(
'wp_usermeta',
array(
'meta_value' => $v1
),
array( 'user_id' => $user, 'meta_key' => 'first_name' ),
array(
'%s'
),
array( '%d', '%s')
);
In local enviroments works perfectly but when I migrated the project to an amazon instance, Ubuntu server using nginx and all the operations using $wpdb are not working.
I cant update, I cant insert.
I dont know why.
Any clue?
I am working in a wordpress site, I started to work in local enviroment using xampp server.
I used wpdb to do operations with the database like this:
global $wpdb;
$name = $wpdb->get_results("SELECT meta_value FROM wp_usermeta WHERE meta_key = 'first_name' AND user_id = ".$user." ");
$wpdb->update(
'wp_usermeta',
array(
'meta_value' => $v1
),
array( 'user_id' => $user, 'meta_key' => 'first_name' ),
array(
'%s'
),
array( '%d', '%s')
);
In local enviroments works perfectly but when I migrated the project to an amazon instance, Ubuntu server using nginx and all the operations using $wpdb are not working.
I cant update, I cant insert.
I dont know why.
Any clue?
Share Improve this question asked Aug 17, 2019 at 20:23 Rivero FelipeRivero Felipe 31 bronze badge1 Answer
Reset to default 0Is there a compelling reason to use $wpdb
for this, and not the API functions get_user_meta()
and update_user_meta()
?
That said, here's something to check: Are you sure that your database prefixes on the server are wp_
? If they're not, then your code won't work as expected.
Try this:
global $wpdb;
$name = $wpdb->get_results("SELECT meta_value FROM {$wpdb->prefix}usermeta WHERE meta_key = 'first_name' AND user_id = ".$user." ");
$wpdb->update(
$wpdb->prefix . 'usermeta',
array(
'meta_value' => $v1
),
array( 'user_id' => $user, 'meta_key' => 'first_name' ),
array(
'%s'
),
array( '%d', '%s')
);
本文标签: Why wpdbgtinsert and wpdbgtupdate not working server but it is working in localhost
版权声明:本文标题:Why $wpdb->insert and $wpdb->update not working server but it is working in localhost? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745235305a2649009.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论