gpt4 book ai didi

mysql - Wordpress MySQL 结果资源无效

转载 作者:行者123 更新时间:2023-11-29 04:23:17 25 4
gpt4 key购买 nike

我有 wp_places 自定义表格,我在打印数组时得到了这个:

[0] => stdClass Object
(
[home_location] => 24
)

[1] => stdClass Object
(
[home_location] => 29
)

现在我想像这样内爆值 (24,29) 但在我的代码中出现此错误:

<b>Warning</b>:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource

我的代码

$getGroupType = $_POST['parent_category'];
$result = $wpdb->get_results( "SELECT home_location FROM wp_places WHERE blood_group LIKE '".$getGroupType."%'" );


$bgroup = Array();
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$bgroup[] = implode(',',$row);
}
echo implode(',',$bgroup);

有什么想法或建议吗?谢谢。

最佳答案

$wpdb->get_results() 已经为你完成了抓取,你不需要调用 mysql_fetch_array

鉴于你想做什么,你的代码应该是这样的:

$getGroupType = $_POST['parent_category'];
$result = $wpdb->get_results( "SELECT home_location FROM wp_places WHERE blood_group LIKE '".$getGroupType."%'" );


$bgroup = Array();
foreach ($result as $location) {
$bgroup[] = $location->home_location;
}
echo '('.implode(',',$bgroup).')';

关于mysql - Wordpress MySQL 结果资源无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17408812/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com