doueta6642 2018-11-27 23:12 采纳率: 0%
浏览 41
已采纳

Wordpress simple_html_dom.php管理页面

I've made as script using file_get_html. I'm now transfering it to a Wordpress site, and it doesn't seem to work.

Just trying to use it in a admin plugin.

Snippet below:

require('includes/simple_html_dom.php');
if (isset($_POST['submit_updateColors'])) {
        $qGetBrands = $mysqli->query("SELECT ... ");
        while ($rowBrands = $qGetBrands->fetch_assoc()) {

            $brandId = $rowBrands['cl_brand_Id'];
            $url =  "https://www.url.com". $rowBrands['cl_brand_url'];
            $html = file_get_html($url);
            $html->find('div[class=col-md-1p5]');

            foreach($html->find('div[class=col-md-1p5]') as $brandColors) {
                foreach ($brandColors->find('h3') as $brandColor) {
                    $p_brandColor = $brandColor->innertext;
                }

                foreach ($brandColors->find('img') as $ColorImg) {
                    $p_ColorImg = $ColorImg->src;
                }                   
                    echo $p_brandColor ." <br />";
                    echo $imgName['basename'] ." <br /> <br />";
            }
        }
    }

After while have started: echo "I'm here!!!" Results: "I'm here!!!"

After first foreach: echo "I'm here!!!" Results: Nothing

After $html = file_get_html($url);: echo "Result: ".$html; Results: Nothing, not even showing "Result"

Error messages:

Fatal error: Uncaught Error: Call to a member function find() on boolean in /home/xxx/public_html/wp-content/plugins/Farbkarte/index.php:67 Stack trace: #0 /home/xxx/public_html/wp-includes/class-wp-hook.php(286): main_init('') #1 /home/xxx/public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array) #2 /home/xxx/public_html/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #3 /home/xxx/public_html/wp-admin/admin.php(224): do_action('toplevel_page_f...') #4 {main} thrown in /home/xxx/public_html/wp-content/plugins/Farbkarte/index.php on line 67

I have no idea how to proceed, and would love to get some help! Outside wordpress, it works perfectly.

I hope I havent removed too much informaton.

Thanks in advance!

  • 写回答

2条回答 默认 最新

  • doupeng6890 2018-11-28 11:57
    关注

    I was able to solve this by looking at file_get_contents(): stream does not support seeking / When was PHP behavior about this changed?

    On line 75 of simple_html_dom.php:

    $contents = file_get_contents($url, $use_include_path, $context, $offset); I removed the reference to $offset:

    $contents = file_get_contents($url, $use_include_path, $context); No my page works fine. Not taking liability for anything else it breaks! :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题