"select " . TABLE_PREFIX.DB_USERTABLE . "." . DB_USERTABLE_USERID .
" userid, " . TABLE_PREFIX.DB_USERTABLE . "." . DB_USERTABLE_NAME .
" username, " . TABLE_PREFIX.DB_USERTABLE . "." . DB_USERTABLE_NAME .
" link, " . DB_AVATARFIELD .
" avatar,substring_index(substring_index(wp_usermeta.meta_value ,'"',-2),'"',1) role from " .
TABLE_PREFIX.DB_USERTABLE .
"left join wp_usermeta on " . TABLE_PREFIX.DB_USERTABLE .
"." . DB_USERTABLE_USERID .
"= wp_usermeta.user_id left join cometchat_status on " .
TABLE_PREFIX.DB_USERTABLE . "." . DB_USERTABLE_USERID .
" = cometchat_status.userid " . DB_AVATARTABLE .
" where (select count(*) from wp_bp_friends where (initiator_user_id='" .
$userid .
"' and friend_user_id=wp_users.ID) or (initiator_user_id=wp_users.ID and friend_user_id='" .
$userid .
"'))=1 and wp_usermeta.meta_key = 'wp_capabilities' order by username asc"
子字符串出现错误,我该如何避免。
问题是语句的这一部分:
" avatar,substring_index(substring_index(wp_usermeta.meta_value ,'"',-2),'"',1) role from "
您正在使用"
定界PHP字符串,但在其中试图使用包含的SQL字符串"
。嵌入式引号将终止PHP字符串。您需要转义嵌入的引号:
" avatar,substring_index(substring_index(wp_usermeta.meta_value ,'\"',-2),'\"',1) role from "
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句